{"id":3433,"date":"2025-12-26T18:49:40","date_gmt":"2025-12-26T15:49:40","guid":{"rendered":"https:\/\/www.dchost.com\/blog\/automating-off-site-backups-to-object-storage-with-rclone-restic-and-cron\/"},"modified":"2026-11-04T18:36:21","modified_gmt":"2026-11-04T15:36:21","slug":"object-storage-backups","status":"publish","type":"post","link":"https:\/\/www.dchost.com\/blog\/en\/object-storage-backups\/","title":{"rendered":"Object Storage Backups for cPanel and VPS"},"content":{"rendered":"<div class=\"dchost-blog-content-wrapper\"><p><strong>Object storage backups for cPanel and VPS<\/strong> can keep a recovery copy outside the source server\u2019s failure domain. This guide uses <strong>rclone<\/strong> to copy completed account archives, <strong>restic<\/strong> for encrypted incremental file backups and <strong>cron<\/strong> for scheduling. Examples require a Linux root Bash shell; per-account hosting permissions are covered separately. Select a supported S3-compatible target outside the source failure domain, whether your <a href=\"https:\/\/www.dchost.com\/vps\">VPS<\/a> or <a href=\"https:\/\/www.dchost.com\/dedicated-server\">dedicated server<\/a> is hosted by DCHost or another provider.<\/p>\n<p>If you already understand why backups are important, your next question is usually: <em>\u201cHow do I automate this in a clean, testable way while monitoring jobs and checking restores?\u201d<\/em> That is exactly what we will cover: what to back up on cPanel\/VPS, how to structure your object storage buckets, how to configure rclone and restic securely, how to schedule jobs with Cron, and how to test restores so you know the whole chain really works.<\/p>\n<div id=\"toc_container\" role=\"navigation\" aria-label=\"Table of Contents\" data-nosnippet class=\"toc_transparent no_bullets toc_numbered toc_title_center\"><p class=\"toc_title\">\u0130\u00e7indekiler<\/p><ul class=\"toc_list\"><li><a href=\"#Why_OffSite_Backups_to_Object_Storage_Matter\"><span class=\"toc_number toc_depth_1\">1.<\/span> Why Off\u2011Site Backups to Object Storage Matter<\/a><\/li><li><a href=\"#Architecture_cPanelVPS_Object_Storage_rclone_restic_Cron\"><span class=\"toc_number toc_depth_1\">2.<\/span> Architecture: cPanel\/VPS + Object Storage + rclone + restic + Cron<\/a><\/li><li><a href=\"#Preparing_Your_Object_Storage_Target\"><span class=\"toc_number toc_depth_1\">3.<\/span> Preparing Your Object Storage Target<\/a><\/li><li><a href=\"#Installing_and_Configuring_rclone_for_S3Compatible_Storage\"><span class=\"toc_number toc_depth_1\">4.<\/span> Installing and Configuring rclone for S3\u2011Compatible Storage<\/a><ul><li><a href=\"#Install_rclone_on_a_Linux_VPS_or_cPanel_server\"><span class=\"toc_number toc_depth_2\">4.1.<\/span> Install rclone on a Linux VPS or cPanel server<\/a><\/li><li><a href=\"#Configure_an_S3_remote_in_rclone\"><span class=\"toc_number toc_depth_2\">4.2.<\/span> Configure an S3 remote in rclone<\/a><\/li><\/ul><\/li><li><a href=\"#Setting_Up_Restic_Repositories_for_Encrypted_Deduplicated_Backups\"><span class=\"toc_number toc_depth_1\">5.<\/span> Setting Up Restic Repositories for Encrypted, Deduplicated Backups<\/a><ul><li><a href=\"#Install_restic\"><span class=\"toc_number toc_depth_2\">5.1.<\/span> Install restic<\/a><\/li><li><a href=\"#Environment_variables_for_restic_S3\"><span class=\"toc_number toc_depth_2\">5.2.<\/span> Environment variables for restic + S3<\/a><\/li><li><a href=\"#Initialize_the_restic_repository\"><span class=\"toc_number toc_depth_2\">5.3.<\/span> Initialize the restic repository<\/a><\/li><\/ul><\/li><li><a href=\"#Example_Backup_Flow_for_a_cPanel_Server\"><span class=\"toc_number toc_depth_1\">6.<\/span> Example Backup Flow for a cPanel Server<\/a><ul><li><a href=\"#1_Enable_and_tune_native_cPanel_backups\"><span class=\"toc_number toc_depth_2\">6.1.<\/span> 1. Enable and tune native cPanel backups<\/a><\/li><li><a href=\"#2_Produce_Verify_and_Copy_a_cPanel_Account_Archive\"><span class=\"toc_number toc_depth_2\">6.2.<\/span> 2. Produce, Verify and Copy a cPanel Account Archive<\/a><\/li><li><a href=\"#3_Optional_restic_layer_for_deduplicated_history\"><span class=\"toc_number toc_depth_2\">6.3.<\/span> 3. Optional: restic layer for deduplicated history<\/a><\/li><\/ul><\/li><li><a href=\"#Example_Backup_Flow_for_a_Generic_VPS_Without_cPanel\"><span class=\"toc_number toc_depth_1\">7.<\/span> Example Backup Flow for a Generic VPS (Without cPanel)<\/a><ul><li><a href=\"#1_Define_what_to_back_up\"><span class=\"toc_number toc_depth_2\">7.1.<\/span> 1. Define what to back up<\/a><\/li><li><a href=\"#2_Example_MySQL_dump_restic\"><span class=\"toc_number toc_depth_2\">7.2.<\/span> 2. Example: MySQL dump + restic<\/a><\/li><\/ul><\/li><li><a href=\"#Scheduling_and_Monitoring_with_Cron\"><span class=\"toc_number toc_depth_1\">8.<\/span> Scheduling and Monitoring with Cron<\/a><ul><li><a href=\"#Scheduling_on_a_generic_Linux_VPS\"><span class=\"toc_number toc_depth_2\">8.1.<\/span> Scheduling on a generic Linux VPS<\/a><\/li><li><a href=\"#Scheduling_from_cPanelWHM\"><span class=\"toc_number toc_depth_2\">8.2.<\/span> Scheduling from cPanel\/WHM<\/a><\/li><\/ul><\/li><li><a href=\"#Testing_Restores_Dont_Wait_for_an_Incident\"><span class=\"toc_number toc_depth_1\">9.<\/span> Testing Restores: Don\u2019t Wait for an Incident<\/a><ul><li><a href=\"#Testing_restic_restores\"><span class=\"toc_number toc_depth_2\">9.1.<\/span> Testing restic restores<\/a><\/li><li><a href=\"#Testing_cPanel_restores\"><span class=\"toc_number toc_depth_2\">9.2.<\/span> Testing cPanel restores<\/a><\/li><\/ul><\/li><li><a href=\"#Hardening_Cost_Control_and_Practical_Tips\"><span class=\"toc_number toc_depth_1\">10.<\/span> Hardening, Cost Control and Practical Tips<\/a><ul><li><a href=\"#1_Protect_credentials_and_limit_access\"><span class=\"toc_number toc_depth_2\">10.1.<\/span> 1. Protect credentials and limit access<\/a><\/li><li><a href=\"#2_Use_encryption_correctly\"><span class=\"toc_number toc_depth_2\">10.2.<\/span> 2. Use encryption correctly<\/a><\/li><li><a href=\"#3_Exclude_junk_and_temporary_data\"><span class=\"toc_number toc_depth_2\">10.3.<\/span> 3. Exclude junk and temporary data<\/a><\/li><li><a href=\"#4_Watch_bandwidth_and_storage_costs\"><span class=\"toc_number toc_depth_2\">10.4.<\/span> 4. Watch bandwidth and storage costs<\/a><\/li><li><a href=\"#5_Integrate_with_monitoring_and_runbooks\"><span class=\"toc_number toc_depth_2\">10.5.<\/span> 5. Integrate with monitoring and runbooks<\/a><\/li><\/ul><\/li><li><a href=\"#Bringing_It_All_Together_on_dchostcom_Infrastructure\"><span class=\"toc_number toc_depth_1\">11.<\/span> Bringing It All Together on dchost.com Infrastructure<\/a><\/li><li><a href=\"#Official_Sources\"><span class=\"toc_number toc_depth_1\">12.<\/span> Official Sources<\/a><\/li><\/ul><\/div>\n<h2><span id=\"Why_OffSite_Backups_to_Object_Storage_Matter\">Why Off\u2011Site Backups to Object Storage Matter<\/span><\/h2>\n<p>Modern backup strategy is no longer just \u201ccopy files to another folder\u201d. Between ransomware, accidental deletions, hardware failures and region\u2011wide incidents, you need a design that survives <strong>multiple failure modes<\/strong>. The classic pattern for this is the <strong>3\u20112\u20111 backup strategy<\/strong>: three copies of your data, on two different media, with one copy off\u2011site. If this sounds new to you, we recommend reading our detailed guide <a href=\"https:\/\/www.dchost.com\/blog\/en\/3-2-1-backups-cpanel-plesk-vps\/\">explaining the 3\u20112\u20111 backup strategy and how to automate it on cPanel and VPS<\/a>.<\/p>\n<p>S3\u2011compatible <strong>object storage<\/strong> can serve as the off\u2011site part of 3\u20112\u20111 when it is independent of the source server&#8217;s location:<\/p>\n<ul>\n<li><strong>Durability:<\/strong> Verify the service\u2019s replication and failure domains. A single-node deployment does not provide multi-region protection.<\/li>\n<li><strong>Costs:<\/strong> Include capacity, API requests, verification reads, restores and minimum charges.<\/li>\n<li><strong>Automation:<\/strong> rclone and restic support S3 backends; verify the selected endpoint and permissions.<\/li>\n<li><strong>Location:<\/strong> An independent region can reduce shared failures; residency and legal requirements need separate assessment.<\/li>\n<\/ul>\n<p>If you want a broader comparison of storage types, we also have a detailed article on <a href=\"https:\/\/www.dchost.com\/blog\/en\/object-block-file-storage-web-apps-backups\/\">Object Storage vs Block Storage vs File Storage and which one to choose for web apps and backups<\/a>.<\/p>\n<h2><span id=\"Architecture_cPanelVPS_Object_Storage_rclone_restic_Cron\">Architecture: cPanel\/VPS + Object Storage + rclone + restic + Cron<\/span><\/h2>\n<p>Before writing any scripts, it helps to be clear on the overall architecture. For a typical cPanel or generic Linux VPS server, a clean design looks like this:<\/p>\n<ul>\n<li><strong>Source server<\/strong>: cPanel server or unmanaged VPS where your sites, databases and emails live.<\/li>\n<li><strong>Local backup staging<\/strong>: a directory on the same server (for example <code>\/backup<\/code> or <code>\/var\/backups<\/code>) where we generate daily backups or cPanel account archives.<\/li>\n<li><strong>restic repository<\/strong>: an encrypted backup repository stored directly in S3\u2011compatible object storage.<\/li>\n<li><strong>rclone remote<\/strong>: a configured connection to your S3\u2011compatible storage endpoint.<\/li>\n<li><strong>Cron jobs<\/strong>: scheduled tasks that run backup scripts (files + databases) and send them to the restic repository via S3.<\/li>\n<\/ul>\n<p>There are two main patterns you can combine:<\/p>\n<ul>\n<li><strong>Native cPanel archives + rclone:<\/strong> Produce completed compressed account archives and copy each to a unique remote prefix. Encryption and archive retention are separate from the restic workflow.<\/li>\n<li><strong>restic directly to S3:<\/strong> Back up selected files and completed SQL dumps. File-level history is not a replacement for cPanel account metadata or a server rebuild plan.<\/li>\n<\/ul>\n<p>You can use both patterns: preserve <strong>native cPanel restore points<\/strong> and also maintain a <strong>restic repository<\/strong> for quick granular restores. Our other article <a href=\"https:\/\/www.dchost.com\/blog\/en\/restic-borg-offsite-backups-s3-storage\/\">on off\u2011site backups with restic\/Borg to S3\u2011compatible storage<\/a> goes deeper into the theory; here we will focus more on concrete scripts for cPanel\/VPS. Automated full-account restoration is performed through WHM by an authorized administrator or hosting provider. The cPanel Backup interface can restore appropriate partial backups; manually extracting public_html files from a full archive does not restore the whole account. Confirm the required access and full restoration procedure before relying on this backup path.<\/p>\n<h2><span id=\"Preparing_Your_Object_Storage_Target\">Preparing Your Object Storage Target<\/span><\/h2>\n<p>First, you need an S3\u2011compatible object storage endpoint and credentials. This could be:<\/p>\n<ul>\n<li>A third-party S3-compatible service whose supported endpoint and permissions you verify.<\/li>\n<li>A self-managed deployment in a separate failure domain; availability depends on its nodes, disks and operations. Our <a href=\"https:\/\/www.dchost.com\/blog\/en\/production-ready-minio-on-a-vps-the-friendly-guide-to-erasure-coding-tls-and-s3-style-bucket-policies\/\">MinIO deployment guide<\/a> discusses architecture; a single node is not equivalent to multi-region redundancy.<\/li>\n<\/ul>\n<p>Create a dedicated <strong>bucket<\/strong> for backups, for example:<\/p>\n<ul>\n<li>Example bucket: <code>company-backups<\/code>.<\/li>\n<li>Keep independent archive and repository prefixes: <code>cpanel\/server01\/account\/run-id<\/code>, <code>restic-vps<\/code> and <code>restic-cpanel<\/code>.<\/li>\n<li>Do not age-expire objects inside restic repositories: old data can still be referenced by current snapshots. Archive lifecycle rules require a separate retention\/recovery plan.<\/li>\n<\/ul>\n<p>Then create an <strong>access key<\/strong> and <strong>secret key<\/strong> for a user that has permissions restricted to that bucket only (least privilege). Keep these credentials safe; we will store them in a root\u2011only configuration file or in environment variables on the server.<\/p>\n<h2><span id=\"Installing_and_Configuring_rclone_for_S3Compatible_Storage\">Installing and Configuring rclone for S3\u2011Compatible Storage<\/span><\/h2>\n<p><strong>rclone<\/strong> is a versatile command\u2011line tool that can sync files and directories to many cloud backends, including S3\u2011compatible services supported by its S3 backend.<\/p>\n<h3><span id=\"Install_rclone_on_a_Linux_VPS_or_cPanel_server\">Install rclone on a Linux VPS or cPanel server<\/span><\/h3>\n<p>Use a suitable package from your distribution\u2019s supported repositories. For Debian\/Ubuntu, for example:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">sudo apt update\nsudo apt install rclone\n<\/code><\/pre>\n<p>On AlmaLinux\/Rocky\/other RHEL derivatives, if rclone is available in your enabled repositories:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">sudo dnf install rclone\n<\/code><\/pre>\n<p>An alternative is the official release archive. The following Linux amd64 version and SHA-256 were checked on 4 November 2026. Use an empty working directory with curl, unzip, bzip2 and sha256sum. Other versions or CPU architectures need their own matching package and checksum; changing only the version variable is insufficient.<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">(\n    set -euo pipefail\n    rclone_version=1.75.2\n    curl -fLO &quot;https:\/\/downloads.rclone.org\/v${rclone_version}\/rclone-v${rclone_version}-linux-amd64.zip&quot;\n    printf &#039;%s  %s\\n&#039; &#039;349ac8fba6ff65d6247043f1750cdcb518ec5d500ef91463a10d37c0ccdf3702&#039; \\\n        &quot;rclone-v${rclone_version}-linux-amd64.zip&quot; | sha256sum -c -\n    unzip &quot;rclone-v${rclone_version}-linux-amd64.zip&quot;\n    install -m 755 &quot;rclone-v${rclone_version}-linux-amd64\/rclone&quot; \/usr\/local\/bin\/rclone\n    \/usr\/local\/bin\/rclone version\n)\n<\/code><\/pre>\n<h3><span id=\"Configure_an_S3_remote_in_rclone\">Configure an S3 remote in rclone<\/span><\/h3>\n<p>Run the configuration wizard as root:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">sudo rclone config\n<\/code><\/pre>\n<p>Follow the interactive prompts:<\/p>\n<ul>\n<li>Name the remote <code>backup-s3<\/code> and choose storage type <code>s3<\/code>.<\/li>\n<li>Select the listed provider, or <code>Other<\/code> for a generic S3-compatible service.<\/li>\n<li>Set endpoint, region, authentication, ACL and storage class according to provider documentation. <code>https:\/\/objects.example.com<\/code> is a placeholder.<\/li>\n<li>The bucket belongs in command paths such as <code>backup-s3:company-backups\/cpanel<\/code>; do not assume it is a wizard setting.<\/li>\n<\/ul>\n<p>When done, test whether the configuration can list the bucket:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">rclone lsf backup-s3:company-backups --max-depth 1\n<\/code><\/pre>\n<p>An empty bucket can return no output with exit status 0. This does not verify write\/read access. Upload a small file to a separate test prefix and compare it with <code>rclone check --download<\/code>. Protect the actual config path shown by <code>rclone config file<\/code> with root ownership and mode 600.<\/p>\n<h2><span id=\"Setting_Up_Restic_Repositories_for_Encrypted_Deduplicated_Backups\">Setting Up Restic Repositories for Encrypted, Deduplicated Backups<\/span><\/h2>\n<p><strong>restic<\/strong> is a modern backup program that offers encrypted, incremental, deduplicated backups and can store data directly in S3\u2011compatible object storage.<\/p>\n<h3><span id=\"Install_restic\">Install restic<\/span><\/h3>\n<p>On Debian\/Ubuntu:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">sudo apt update\nsudo apt install restic\n<\/code><\/pre>\n<p>For a suitable RHEL repository package, follow your distribution\u2019s instructions. Alternatively, the official restic 0.19.1 Linux amd64 archive below was checked on 4 November 2026; it requires decompression and a matching checksum. The later scripts also require Bash, flock, gzip and jq in cron\u2019s PATH.<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">(\n    set -euo pipefail\n    restic_version=0.19.1\n    curl -fLO &quot;https:\/\/github.com\/restic\/restic\/releases\/download\/v${restic_version}\/restic_${restic_version}_linux_amd64.bz2&quot;\n    printf &#039;%s  %s\\n&#039; &#039;f415415624dcc452f2a02b8c33641791a8c6d6d3b65bbb3543fcf9a25151585c&#039; \\\n        &quot;restic_${restic_version}_linux_amd64.bz2&quot; | sha256sum -c -\n    bzip2 -dk &quot;restic_${restic_version}_linux_amd64.bz2&quot;\n    install -m 755 &quot;restic_${restic_version}_linux_amd64&quot; \/usr\/local\/bin\/restic\n    \/usr\/local\/bin\/restic version\n)\n<\/code><\/pre>\n<h3><span id=\"Environment_variables_for_restic_S3\">Environment variables for restic + S3<\/span><\/h3>\n<p>Use separate protected files: <code>\/root\/restic-vps.env<\/code> and <code>\/root\/restic-cpanel.env<\/code>. Create the VPS file below with root ownership and mode 600, replace every placeholder and create a separate mode-600 password file containing the real strong repository password. Keep its secure recovery copy outside this server. Do not overwrite an existing environment\/password file when adding another workflow.<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">export RESTIC_REPOSITORY=&#039;s3:https:\/\/objects.example.com\/company-backups\/restic-vps&#039;\nexport RESTIC_PASSWORD_FILE=&#039;\/root\/restic-vps.password&#039;\nexport AWS_ACCESS_KEY_ID=&#039;REPLACE_WITH_ACCESS_KEY&#039;\nexport AWS_SECRET_ACCESS_KEY=&#039;REPLACE_WITH_SECRET_KEY&#039;\nexport BACKUP_HOST=&#039;server01&#039;\n<\/code><\/pre>\n<p>Secure the file:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">chown root:root \/root\/restic-vps.env \/root\/restic-vps.password\nchmod 600 \/root\/restic-vps.env \/root\/restic-vps.password\n<\/code><\/pre>\n<h3><span id=\"Initialize_the_restic_repository\">Initialize the restic repository<\/span><\/h3>\n<p>Run the following commands in a root Bash shell, with the environment variables loaded from the protected file, to initialize the repository:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">source \/root\/restic-vps.env\nrestic init\n<\/code><\/pre>\n<p>Run init only once for the intended new repository. For an existing repository, verify access using <code>restic snapshots<\/code>. Losing the password can make intact backup objects unrecoverable. AWS-prefixed environment variable names are also used with supported non-AWS S3 endpoints.<\/p>\n<h2><span id=\"Example_Backup_Flow_for_a_cPanel_Server\">Example Backup Flow for a cPanel Server<\/span><\/h2>\n<p>On cPanel\/WHM, you usually want two layers:<\/p>\n<ul>\n<li>cPanel&#039;s <strong>native backups<\/strong> (account\u2011level archives for easy full account restores).<\/li>\n<li>Optionally, a <strong>restic layer<\/strong> for deduplicated, long\u2011retention backups across many days or weeks.<\/li>\n<\/ul>\n<h3><span id=\"1_Enable_and_tune_native_cPanel_backups\">1. Enable and tune native cPanel backups<\/span><\/h3>\n<p>In WHM, go to <strong>Backup Configuration<\/strong> and:<\/p>\n<ul>\n<li>Enable backups and choose the documented mode for your recovery plan. This article\u2019s transport path uses compressed account archives.<\/li>\n<li>Set an appropriate local directory and retention; verify the supported additional destinations for the chosen cPanel mode.<\/li>\n<li>Incremental raw directory trees copied to S3 do not by themselves demonstrate full account restoration with metadata.<\/li>\n<li>A full archive may omit settings such as account 2FA; verify source\/target version compatibility and document required reconfiguration.<\/li>\n<\/ul>\n<p>If you want a detailed walkthrough of cPanel backup options, see our <a href=\"https:\/\/www.dchost.com\/blog\/en\/cpanel-backup-restore-files-databases-email\/\">Full cPanel Backup and Restore guide<\/a>.<\/p>\n<h3><span id=\"2_Produce_Verify_and_Copy_a_cPanel_Account_Archive\">2. Produce, Verify and Copy a cPanel Account Archive<\/span><\/h3>\n<p>The root-only example below waits for <code>pkgacct<\/code> in the same job. It does not infer completion from a later clock time. First prepare staging directories; create <code>\/root\/cpanel-archive.env<\/code> as root:root\/600 with the settings shown. Save the script as <code>\/opt\/backups\/cpanel-backup.sh<\/code>. Official pkgacct guidance requires free space exceeding twice the largest account plus an additional 1 GB on both source and destination; allow more for retained runs and logs.<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">umask 077\ninstall -d -m 700 \/opt\/backups \/opt\/backups\/db-dumps \/opt\/backups\/status \/opt\/backups\/cpanel\n<\/code><\/pre>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">ARCHIVE_REMOTE=&#039;backup-s3:company-backups\/cpanel&#039;\nBACKUP_HOST=&#039;server01&#039;\n<\/code><\/pre>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">#!\/usr\/bin\/env bash\nset -euo pipefail\numask 077\nexport PATH=\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin\naccount=${1:?Usage: cpanel-backup.sh CPANEL_ACCOUNT}\n[[ &quot;$account&quot; =~ ^[a-z][a-z0-9_]{0,15}$ ]] || exit 64\n[[ -f &quot;\/var\/cpanel\/users\/$account&quot; ]] || exit 66\nsource \/root\/cpanel-archive.env\n: &quot;${ARCHIVE_REMOTE:?}&quot; &quot;${BACKUP_HOST:?}&quot;\n[[ &quot;$BACKUP_HOST&quot; =~ ^[A-Za-z0-9._-]+$ ]] || exit 64\nexec 9&gt;\/opt\/backups\/.backup.lock\nflock -n 9 || { printf &#039;Backup lock is busy.\\n&#039; &gt;&amp;2; exit 75; }\ninstall -d -m 700 \/opt\/backups\/cpanel \/opt\/backups\/status\nwork=$(mktemp -d \/opt\/backups\/cpanel\/.run.XXXXXX)\ntrap &#039;printf &quot;Local run directory retained: %s\\n&quot; &quot;$work&quot; &gt;&amp;2&#039; EXIT\ninstall -d -m 700 &quot;$work\/package&quot; &quot;$work\/ready&quot;\n\/usr\/local\/cpanel\/scripts\/pkgacct --backup --dbbackup=all \\\n    &quot;$account&quot; &quot;$work\/package&quot; &gt; &quot;$work\/pkgacct.log&quot; 2&gt;&amp;1\nif ! grep -qF &#039;pkgacct completed&#039; &quot;$work\/pkgacct.log&quot;; then\n    printf &#039;No successful pkgacct completion marker; inspect %s\\n&#039; &quot;$work\/pkgacct.log&quot; &gt;&amp;2\n    exit 65\nfi\narchive=&quot;$work\/package\/$account.tar.gz&quot;\n[[ -s &quot;$archive&quot; ]] || exit 66\ngzip -t &quot;$archive&quot;\nmv -- &quot;$archive&quot; &quot;$work\/ready\/$account.tar.gz&quot;\nrun_id=&quot;$(date -u +%Y%m%dT%H%M%SZ)-${work##*.}&quot;\ndestination=&quot;${ARCHIVE_REMOTE%\/}\/$BACKUP_HOST\/$account\/$run_id&quot;\nrclone copy &quot;$work\/ready&quot; &quot;$destination&quot; --immutable \\\n    --transfers=1 --checkers=2 --bwlimit=5M\nrclone check &quot;$work\/ready&quot; &quot;$destination&quot; --download --one-way\nstate=$(mktemp \/opt\/backups\/status\/.cpanel-state.XXXXXX)\nprintf &#039;%s %s\\n&#039; &quot;$(date -u +%FT%TZ)&quot; &quot;$destination&quot; &gt; &quot;$state&quot;\nmv -f -- &quot;$state&quot; &quot;\/opt\/backups\/status\/cpanel-$account-last-success&quot;\nprintf &#039;Verified archive destination: %s\\n&#039; &quot;$destination&quot;\n<\/code><\/pre>\n<p>Make it executable:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">chown root:root \/opt\/backups\/cpanel-backup.sh\nchmod 700 \/opt\/backups\/cpanel-backup.sh\n<\/code><\/pre>\n<p>Test the script manually with a real account name before scheduling and verify the pkgacct completion marker on your installed cPanel version. It retains local run directories and logs on both success and failure: define a separate cleanup policy after remote verification and monitor disk capacity. <code>copy<\/code> preserves destination-only files; <code>--immutable<\/code> rejects changed existing files. <code>sync<\/code> and <code>--delete-excluded<\/code> can remove retained copies. Read-back comparison downloads data and can incur charges. The local flock only coordinates cooperating jobs on this host; avoid overlap with independent WHM schedulers and other writers.<\/p>\n<h3><span id=\"3_Optional_restic_layer_for_deduplicated_history\">3. Optional: restic layer for deduplicated history<\/span><\/h3>\n<p>For optional file-level history, use <code>\/root\/restic-cpanel.env<\/code>, a separate repository and password file. This layer backs up selected live paths and completed dumps; it does not replace native full account archives. Deduplication savings depend on actual data.<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">export RESTIC_REPOSITORY=&#039;s3:https:\/\/objects.example.com\/company-backups\/restic-cpanel&#039;\nexport RESTIC_PASSWORD_FILE=&#039;\/root\/restic-cpanel.password&#039;\nexport AWS_ACCESS_KEY_ID=&#039;REPLACE_WITH_ACCESS_KEY&#039;\nexport AWS_SECRET_ACCESS_KEY=&#039;REPLACE_WITH_SECRET_KEY&#039;\nexport BACKUP_HOST=&#039;server01&#039;\n<\/code><\/pre>\n<p>Replace placeholders, create <code>\/root\/restic-cpanel.password<\/code>, and protect both files as root:root\/600. Keep an off-server recovery copy of the password. Initialize this new repository once:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">source \/root\/restic-cpanel.env\nrestic init\n<\/code><\/pre>\n<p>Save the following as <code>\/opt\/backups\/restic-cpanel-backup.sh<\/code>, root:root\/700. It requires the database helper and configuration in the next section before it can run. Select the databases for these accounts explicitly; do not assume the example list covers every account.<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">#!\/usr\/bin\/env bash\nset -euo pipefail\numask 077\nexport PATH=\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin\nexec 9&gt;\/opt\/backups\/.backup.lock\nflock -n 9 || { printf &#039;Backup lock is busy.\\n&#039; &gt;&amp;2; exit 75; }\nsource \/root\/restic-cpanel.env\nsource \/opt\/backups\/db-dump.sh\n: &quot;${BACKUP_HOST:?}&quot;\n[[ -d \/home &amp;&amp; -d \/etc &amp;&amp; -d \/var\/named ]] || exit 66\ninstall -d -m 700 \/opt\/backups\/status\nresult=$(mktemp \/opt\/backups\/status\/.cpanel-files-result.XXXXXX)\nstate=$(mktemp \/opt\/backups\/status\/.cpanel-files-state.XXXXXX)\ntrap &#039;rm -f -- &quot;$result&quot; &quot;$state&quot;&#039; EXIT\nmake_database_dump\nrestic backup \/home \/etc \/var\/named \/opt\/backups\/db-dumps\/databases.sql.gz \\\n    --host &quot;$BACKUP_HOST&quot; --tag cpanel-files --json &gt; &quot;$result&quot;\nsnapshot_id=$(jq -er &#039;select(.message_type == &quot;summary&quot;) | .snapshot_id&#039; &quot;$result&quot;)\n[[ &quot;$snapshot_id&quot; =~ ^[0-9a-f]{64}$ ]] || exit 65\nprintf &#039;%s %s\\n&#039; &quot;$(date -u +%FT%TZ)&quot; &quot;$snapshot_id&quot; &gt; &quot;$state&quot;\nmv -f -- &quot;$state&quot; \/opt\/backups\/status\/cpanel-files-last-success\ncat &quot;$result&quot;\n<\/code><\/pre>\n<p>The job covers <code>\/home<\/code>, <code>\/etc<\/code>, <code>\/var\/named<\/code> and the completed dump file. Inventory real paths, nested mounts and symlink targets before using it: restic stores symlinks without following them. Live files and SQL are not automatically one application-consistent point; coordinate writes or use an application-appropriate snapshot process. A nonzero restic result, including partial-backup code 3, does not update the last-success record.<\/p>\n<h2><span id=\"Example_Backup_Flow_for_a_Generic_VPS_Without_cPanel\">Example Backup Flow for a Generic VPS (Without cPanel)<\/span><\/h2>\n<p>On an unmanaged VPS (for example hosting a Laravel or Node.js app), you usually control everything via SSH. Here is an example pattern to adapt to your application.<\/p>\n<h3><span id=\"1_Define_what_to_back_up\">1. Define what to back up<\/span><\/h3>\n<p>For a typical Linux VPS running web applications, you want:<\/p>\n<ul>\n<li><strong>Application code and uploads<\/strong>: for example <code>\/var\/www<\/code> or <code>\/opt\/apps<\/code>.<\/li>\n<li><strong>Databases<\/strong>: MySQL\/MariaDB, PostgreSQL, etc. Usually via logical dumps or snapshot tools.<\/li>\n<li><strong>Configuration<\/strong>: <code>\/etc<\/code> (web server, PHP\u2011FPM, system config).<\/li>\n<li><strong>Optional logs<\/strong>: at least for short retention, if you need to investigate incidents.<\/li>\n<\/ul>\n<p>We have a separate article on <a href=\"https:\/\/www.dchost.com\/blog\/en\/mysql-backup-strategies-mysqldump-percona-xtrabackup-or-snapshots\/\">MySQL backup strategies (mysqldump vs XtraBackup vs snapshots)<\/a> if you want to design your database backup layer in more detail.<\/p>\n<h3><span id=\"2_Example_MySQL_dump_restic\">2. Example: MySQL dump + restic<\/span><\/h3>\n<p>Create <code>\/opt\/backups\/db-dump.sh<\/code> with the function below. The main locked job sources it; do not schedule it independently. Configure <code>\/root\/backup-database.env<\/code> with <code>mysql<\/code> or <code>mariadb<\/code> and explicit application database names. <code>\/root\/backup-mysql.cnf<\/code> supplies supported authentication. Protect both files with root ownership and mode 600; test permissions for selected tables, views, routines, events and triggers.<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">umask 077\ninstall -d -m 700 \/opt\/backups \/opt\/backups\/db-dumps \/opt\/backups\/status \/opt\/backups\/cpanel\n<\/code><\/pre>\n<p>The database-name validation accepts letters, digits and underscores only; adapt it deliberately for other naming schemes. A raw MySQL data directory is not equivalent to a completed logical dump.<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">DB_FLAVOR=mysql\nDB_DEFAULTS_FILE=\/root\/backup-mysql.cnf\nDB_NAMES=(application_db)\n<\/code><\/pre>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">[client]\nuser=backup_user\npassword=REPLACE_WITH_DATABASE_PASSWORD\n<\/code><\/pre>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">#!\/usr\/bin\/env bash\n# Source this file from a backup job holding \/opt\/backups\/.backup.lock.\nmake_database_dump() (\n    set -euo pipefail\n    umask 077\n    source \/root\/backup-database.env\n    : &quot;${DB_FLAVOR:?}&quot; &quot;${DB_DEFAULTS_FILE:?}&quot;\n    (( ${#DB_NAMES[@]} &gt; 0 )) || exit 64\n    [[ -r &quot;$DB_DEFAULTS_FILE&quot; ]] || exit 66\n    for database in &quot;${DB_NAMES[@]}&quot;; do\n        [[ &quot;$database&quot; =~ ^[A-Za-z0-9_]+$ ]] || exit 64\n    done\n    case &quot;$DB_FLAVOR&quot; in\n        mysql) dump_command=mysqldump; extra=(--set-gtid-purged=OFF) ;;\n        mariadb) dump_command=mariadb-dump; extra=() ;;\n        *) printf &#039;Set DB_FLAVOR to mysql or mariadb.\\n&#039; &gt;&amp;2; exit 64 ;;\n    esac\n    dump_dir=\/opt\/backups\/db-dumps\n    install -d -m 700 &quot;$dump_dir&quot;\n    partial=$(mktemp &quot;$dump_dir\/.databases.sql.gz.XXXXXX&quot;)\n    trap &#039;rm -f -- &quot;$partial&quot;&#039; EXIT\n    &quot;$dump_command&quot; --defaults-extra-file=&quot;$DB_DEFAULTS_FILE&quot; \\\n        --single-transaction --quick --routines --events --triggers \\\n        --no-tablespaces &quot;${extra[@]}&quot; --databases &quot;${DB_NAMES[@]}&quot; \\\n        | gzip &gt; &quot;$partial&quot;\n    gzip -t &quot;$partial&quot;\n    mv -f -- &quot;$partial&quot; &quot;$dump_dir\/databases.sql.gz&quot;\n)\n<\/code><\/pre>\n<p><code>--single-transaction<\/code> provides consistency for transactional tables such as InnoDB; MyISAM\/MEMORY tables can change during the dump. Do not run ALTER\/CREATE\/DROP\/RENAME\/TRUNCATE while it runs. The MySQL branch disables GTID transfer and is not a replication\/PITR setup; the MariaDB branch uses its own client. This application dump omits unselected databases, account grants, general tablespace definitions and other server metadata. PostgreSQL and physical-backup tools require their own coordinated workflow. The helper keeps the previous completed dump if generation fails and removes its private partial file.<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">chown root:root \/opt\/backups\/db-dump.sh\nchmod 600 \/opt\/backups\/db-dump.sh\n<\/code><\/pre>\n<p>For the generic VPS job, use the <code>\/root\/restic-vps.env<\/code> prepared earlier. The following is the same configuration, not a new repository to initialize over existing state. Adapt source paths and authentication to the actual application, protect its password file and preserve its off-server recovery copy:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">export RESTIC_REPOSITORY=&#039;s3:https:\/\/objects.example.com\/company-backups\/restic-vps&#039;\nexport RESTIC_PASSWORD_FILE=&#039;\/root\/restic-vps.password&#039;\nexport AWS_ACCESS_KEY_ID=&#039;REPLACE_WITH_ACCESS_KEY&#039;\nexport AWS_SECRET_ACCESS_KEY=&#039;REPLACE_WITH_SECRET_KEY&#039;\nexport BACKUP_HOST=&#039;server01&#039;\n<\/code><\/pre>\n<p>If this new VPS repository has not already been initialized, run the following once. Otherwise use <code>restic snapshots<\/code> to verify it:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">source \/root\/restic-vps.env\nrestic init\n<\/code><\/pre>\n<p>Save the main job as <code>\/opt\/backups\/restic-backup.sh<\/code>. It takes the shared local lock, creates the dump and backs up <code>\/var\/www<\/code>, <code>\/etc<\/code> and only the completed SQL archive. It records the full snapshot ID and UTC completion time only after success:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">#!\/usr\/bin\/env bash\nset -euo pipefail\numask 077\nexport PATH=\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin\nexec 9&gt;\/opt\/backups\/.backup.lock\nflock -n 9 || { printf &#039;Backup lock is busy.\\n&#039; &gt;&amp;2; exit 75; }\nsource \/root\/restic-vps.env\nsource \/opt\/backups\/db-dump.sh\n: &quot;${BACKUP_HOST:?}&quot;\n[[ -d \/var\/www &amp;&amp; -d \/etc ]] || exit 66\ninstall -d -m 700 \/opt\/backups\/status\nresult=$(mktemp \/opt\/backups\/status\/.vps-result.XXXXXX)\nstate=$(mktemp \/opt\/backups\/status\/.vps-state.XXXXXX)\ntrap &#039;rm -f -- &quot;$result&quot; &quot;$state&quot;&#039; EXIT\nmake_database_dump\nrestic backup \/var\/www \/etc \/opt\/backups\/db-dumps\/databases.sql.gz \\\n    --host &quot;$BACKUP_HOST&quot; --tag vps-app --json &gt; &quot;$result&quot;\nsnapshot_id=$(jq -er &#039;select(.message_type == &quot;summary&quot;) | .snapshot_id&#039; &quot;$result&quot;)\n[[ &quot;$snapshot_id&quot; =~ ^[0-9a-f]{64}$ ]] || exit 65\nprintf &#039;%s %s\\n&#039; &quot;$(date -u +%FT%TZ)&quot; &quot;$snapshot_id&quot; &gt; &quot;$state&quot;\nmv -f -- &quot;$state&quot; \/opt\/backups\/status\/vps-last-success\ncat &quot;$result&quot;\n<\/code><\/pre>\n<p>Make it executable:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">chown root:root \/opt\/backups\/restic-backup.sh\nchmod 700 \/opt\/backups\/restic-backup.sh\n<\/code><\/pre>\n<h2><span id=\"Scheduling_and_Monitoring_with_Cron\">Scheduling and Monitoring with Cron<\/span><\/h2>\n<p>Once your scripts work when run manually, the next step is automation with <strong>Cron<\/strong>. We have a separate guide on <a href=\"https:\/\/www.dchost.com\/blog\/en\/cpanel-directadmin-cron-backups-maintenance\/\">automating backups, reports and maintenance with Cron on cPanel and DirectAdmin<\/a>, but we will highlight the essentials here.<\/p>\n<h3><span id=\"Scheduling_on_a_generic_Linux_VPS\">Scheduling on a generic Linux VPS<\/span><\/h3>\n<p>Edit the root user&#039;s crontab:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">sudo crontab -e\n<\/code><\/pre>\n<p>Install only your chosen workflows, after a successful manual run and restore test. These times use the server cron time zone; measure completion duration and choose intervals from your RPO. Local lock contention exits 75 and skips that run, so monitor missing success as well as errors. Do not overlap independent WHM jobs or other hosts writing the same repository.<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\"># Replace CPANEL_ACCOUNT with the real account name.\n0 3 * * * \/opt\/backups\/cpanel-backup.sh CPANEL_ACCOUNT &gt;&gt; \/var\/log\/cpanel-backup.log 2&gt;&amp;1\n# VPS example: every four hours.\n0 *\/4 * * * \/opt\/backups\/restic-backup.sh &gt;&gt; \/var\/log\/restic-backup.log 2&gt;&amp;1\n# Optional cPanel file history; choose a nonconflicting schedule.\n30 4 * * * \/opt\/backups\/restic-cpanel-backup.sh &gt;&gt; \/var\/log\/restic-cpanel-backup.log 2&gt;&amp;1\n<\/code><\/pre>\n<p>Cron can email output that a job leaves on standard output or standard error when mail delivery is configured. These backup scripts redirect their main output, including errors, to log files, so cron mail alone will not report those failures. Monitor exit status and alert when no successful backup completes within the expected interval. In addition, you can:<\/p>\n<ul>\n<li>Monitor <code>\/var\/log\/cpanel-backup.log<\/code>, <code>\/var\/log\/restic-backup.log<\/code> and, if enabled, <code>\/var\/log\/restic-cpanel-backup.log<\/code>.<\/li>\n<li>Push log metrics into your existing monitoring stack (for example Prometheus + alerting), similar to what we describe in our article on <a href=\"https:\/\/www.dchost.com\/blog\/en\/vps-monitoring-prometheus-grafana\/\">VPS monitoring and alerts with Prometheus and Grafana<\/a>.<\/li>\n<\/ul>\n<h3><span id=\"Scheduling_from_cPanelWHM\">Scheduling from cPanel\/WHM<\/span><\/h3>\n<p>On cPanel servers, you can also schedule scripts using:<\/p>\n<ul>\n<li><strong>Root system jobs:<\/strong> use the root user\u2019s crontab for these \/root and \/opt\/backups scripts.<\/li>\n<li><strong>WHM Configure cPanel Cron Jobs:<\/strong> controls upcp, backup and cpbackup schedules; it is not a generic arbitrary-root-script UI.<\/li>\n<li><strong>cPanel Cron Jobs:<\/strong> per-account jobs are limited to that account\u2019s permissions, binaries, quotas and readable paths.<\/li>\n<\/ul>\n<p>A shared-hosting account cannot simply run the root examples. Confirm allowed tools and quotas with the provider, obtain a completed account archive through the supported workflow and agree the full restoration path. A cPanel partial restore is a different operation from an authorized WHM full-account restore.<\/p>\n<h2><span id=\"Testing_Restores_Dont_Wait_for_an_Incident\">Testing Restores: Don\u2019t Wait for an Incident<\/span><\/h2>\n<p>A backup that has never been restored is an assumption, not a guarantee. We strongly recommend including <strong>regular restore tests<\/strong> in your maintenance schedule. This is also a key part of any serious disaster recovery plan; if you are designing one, our guide on <a href=\"https:\/\/www.dchost.com\/blog\/en\/disaster-recovery-plan-rto-rpo-runbooks\/\">how to write a disaster recovery (DR) plan with realistic RPO\/RTO and backup tests<\/a> may help.<\/p>\n<h3><span id=\"Testing_restic_restores\">Testing restic restores<\/span><\/h3>\n<p>List snapshots:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">source \/root\/restic-vps.env\nrestic snapshots --host &quot;$BACKUP_HOST&quot; --tag vps-app\n<\/code><\/pre>\n<p>Select an explicitly recorded successful snapshot ID. The following restores the entire chosen snapshot into a new private directory; it does not select only one website:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">(\n    set -euo pipefail\n    umask 077\n    source \/root\/restic-vps.env\n    restic snapshots --host &quot;$BACKUP_HOST&quot; --tag vps-app\n    read -r completed_at snapshot_id &lt; \/opt\/backups\/status\/vps-last-success\n    [[ &quot;$snapshot_id&quot; =~ ^[0-9a-f]{64}$ ]] || exit 65\n    restore_dir=$(mktemp -d \/opt\/backups\/restore.XXXXXX)\n    chmod 700 &quot;$restore_dir&quot;\n    restic restore &quot;$snapshot_id&quot; --target &quot;$restore_dir&quot;\n    printf &#039;Restore directory: %s\\n&#039; &quot;$restore_dir&quot;\n)\n<\/code><\/pre>\n<p>Check bytes, ownership, permissions, symlinks and application behavior. For selected files, inspect paths using <code>restic ls SNAPSHOT_ID<\/code> and then use <code>--include<\/code>; <code>--path<\/code> selects snapshots rather than filtering restored files. If the source server is lost, obtain the explicit ID from off-server runbook records and snapshot listings. Review CREATE DATABASE\/USE statements before importing SQL with a compatible client on an isolated test server; MariaDB dump sandbox statements may fail in older MariaDB or MySQL clients. Disable real mail, payment and webhook integrations during tests.<\/p>\n<h3><span id=\"Testing_cPanel_restores\">Testing cPanel restores<\/span><\/h3>\n<p>For cPanel native backups:<\/p>\n<ul>\n<li>Download the selected complete archive to a private directory using rclone.<\/li>\n<li>Use WHM\u2019s supported full-backup\/cpmove restoration process through an authorized administrator or provider on a separate test server.<\/li>\n<li>Validate account files, databases, mail, DNS\/SSL and required reconfiguration. cPanel partial restoration or extracting public_html does not recreate the whole account.<\/li>\n<\/ul>\n<p>A successful gzip or transfer check is not proof of application recovery. Verify the actual items required by your account and version; for example, pkgacct documentation excludes transferred 2FA configuration. Record recovery time and the recovered data point against your RTO\/RPO.<\/p>\n<h2><span id=\"Hardening_Cost_Control_and_Practical_Tips\">Hardening, Cost Control and Practical Tips<\/span><\/h2>\n<p>Use these checks when adapting the examples to your workload; service capabilities and recovery results must be verified in your environment.<\/p>\n<h3><span id=\"1_Protect_credentials_and_limit_access\">1. Protect credentials and limit access<\/span><\/h3>\n<ul>\n<li>Store S3 access keys in root\u2011owned files with <code>chmod 600<\/code>, never in world\u2011readable scripts.<\/li>\n<li>Create a dedicated S3 user with <strong>bucket\u2011scoped permissions<\/strong> (no access to other buckets or admin APIs).<\/li>\n<li>Rotate access keys periodically and test after rotation.<\/li>\n<\/ul>\n<h3><span id=\"2_Use_encryption_correctly\">2. Use encryption correctly<\/span><\/h3>\n<ul>\n<li>Restic encrypts repository content client-side. Protect the password file and keep a separate recovery copy; encryption does not prevent a compromised client from exposing plaintext or deleting accessible backups.<\/li>\n<li>For plain rclone archives, <code>crypt<\/code> can provide client-side encryption; test both its configuration and key recovery.<\/li>\n<li>Versioning and Object Lock may add protection where supported, but storage locking, restic lock-object deletion and prune must be tested together. The <a href=\"https:\/\/www.dchost.com\/blog\/en\/s3-object-lock-immutable-backups\/\">S3 Object Lock and recovery guide<\/a> discusses those controls; no tool combination guarantees immunity.<\/li>\n<\/ul>\n<h3><span id=\"3_Exclude_junk_and_temporary_data\">3. Exclude junk and temporary data<\/span><\/h3>\n<p>Backups are not a trash bag for everything on the disk. Excluding some paths improves speed and reduces costs:<\/p>\n<ul>\n<li>Cache directories (for example <code>storage\/framework\/cache<\/code> in Laravel, <code>wp-content\/cache<\/code> in WordPress).<\/li>\n<li>System caches under <code>\/var\/cache<\/code> that can be rebuilt.<\/li>\n<li>Big application logs if you already centralize logs elsewhere (for example Loki\/ELK stack).<\/li>\n<\/ul>\n<p>Use explicit <code>--exclude<\/code> or <code>--exclude-file<\/code> rules only after checking recovery requirements. <code>--exclude-caches<\/code> recognizes CACHEDIR.TAG; it does not mean all application caches. <code>--one-file-system<\/code> can omit nested mounts and subvolumes, so the examples do not add it silently. List required filesystem roots explicitly if you choose that option.<\/p>\n<h3><span id=\"4_Watch_bandwidth_and_storage_costs\">4. Watch bandwidth and storage costs<\/span><\/h3>\n<ul>\n<li>Measure production load and choose off-peak periods, transfer limits and, where effective, nice\/ionice priorities.<\/li>\n<li>Deduplication savings depend on repeated data; compressed\/encrypted dump changes can reduce reuse. Estimate costs using a pilot, including API operations, read-back verification and restores.<\/li>\n<li>Choose retention from recovery and legal requirements, as discussed in our <a href=\"https:\/\/www.dchost.com\/blog\/en\/backup-retention-kvkk-gdpr\/\">backup retention guide<\/a>. Keep policy separate from the daily job.<\/li>\n<\/ul>\n<p>Save the following as <code>\/opt\/backups\/restic-maintenance.sh<\/code>, root:root\/700. Preview first. The explicit <code>apply<\/code> mode deletes expired snapshots and prunes unused data. The 7-day window is relative to each group\u2019s newest snapshot and keeps intraday points; daily\/weekly\/monthly rules combine rather than adding to a guaranteed fixed count. Changing host, source paths or tags can create another group.<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">#!\/usr\/bin\/env bash\nset -euo pipefail\numask 077\nexport PATH=\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin\ncase &quot;${1:-}&quot; in\n    vps) source \/root\/restic-vps.env; backup_tag=vps-app ;;\n    cpanel) source \/root\/restic-cpanel.env; backup_tag=cpanel-files ;;\n    *) printf &#039;Usage: restic-maintenance.sh vps|cpanel [apply]\\n&#039; &gt;&amp;2; exit 64 ;;\nesac\n: &quot;${BACKUP_HOST:?}&quot;\nexec 9&gt;\/opt\/backups\/.backup.lock\nflock -n 9 || { printf &#039;Backup lock is busy.\\n&#039; &gt;&amp;2; exit 75; }\npolicy=(--host &quot;$BACKUP_HOST&quot; --tag &quot;$backup_tag&quot; --group-by host,paths,tags\n        --keep-within 7d --keep-daily 7 --keep-weekly 4 --keep-monthly 6)\ncase &quot;${2:-preview}&quot; in\n    preview) restic forget &quot;${policy[@]}&quot; --dry-run ;;\n    apply) restic forget &quot;${policy[@]}&quot; --prune ;;\n    *) exit 64 ;;\nesac\n<\/code><\/pre>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">\/opt\/backups\/restic-maintenance.sh vps\n# Review first; this next command deletes expired snapshots:\n\/opt\/backups\/restic-maintenance.sh vps apply\n<\/code><\/pre>\n<p>Use <code>cpanel<\/code> for the separate cPanel repository. Coordinate other hosts as prune needs an exclusive repository lock. Do not expire restic objects by age using S3 lifecycle rules or move live repository objects to an inaccessible archive class. Run periodic <code>restic check<\/code>; schedule <code>restic check --read-data<\/code> when you can afford downloading all packs, because the default check does not read all data. Retention counts do not increase backup frequency.<\/p>\n<h3><span id=\"5_Integrate_with_monitoring_and_runbooks\">5. Integrate with monitoring and runbooks<\/span><\/h3>\n<ul>\n<li>Monitor last-success age and command failures, including skipped lock-conflict runs.<\/li>\n<li>Keep successful full snapshot IDs and archive destinations in an off-server monitoring\/runbook record; a local marker can be lost with the server.<\/li>\n<li>Test alert delivery and rehearse site, database and account recovery using a written runbook.<\/li>\n<\/ul>\n<h2><span id=\"Bringing_It_All_Together_on_dchostcom_Infrastructure\">Bringing It All Together on dchost.com Infrastructure<\/span><\/h2>\n<p>The pattern applies to cPanel, VPS, dedicated and colocation workloads hosted by DCHost or another provider: define source scope, generate completed recoverable data, store an independent copy, monitor automation and rehearse restoration. Do not assume an included backup service or a particular Object Storage endpoint; confirm your service\u2019s scope and permissions.<\/p>\n<p>If you are starting from scratch, your practical next steps are:<\/p>\n<ol>\n<li>Choose or deploy an S3\u2011compatible object storage backend and create a dedicated backup bucket.<\/li>\n<li>Install and configure rclone and restic on your cPanel\/VPS servers.<\/li>\n<li>Write minimal backup scripts that you can run manually and verify.<\/li>\n<li>Add Cron schedules and basic monitoring for success\/failure.<\/li>\n<li>Plan and rehearse at least one restore scenario (single site, full server, or critical database).<\/li>\n<\/ol>\n<p>Scale the tested workflow after measuring backup duration, storage growth and restore time. Add regional copies, versioning or object locking only after validating their operational and recovery requirements. Encryption and location choices alone do not establish KVKK\/GDPR compliance; retention, access, deletion and applicable obligations need their own assessment.<\/p>\n<h2><span id=\"Official_Sources\">Official Sources<\/span><\/h2>\n<ul>\n<li><a href=\"https:\/\/docs.cpanel.net\/whm\/scripts\/the-pkgacct-script\/\" rel=\"nofollow noopener\" target=\"_blank\">cPanel: pkgacct<\/a><\/li>\n<li><a href=\"https:\/\/docs.cpanel.net\/cpanel\/files\/backup-for-cpanel\/\" rel=\"nofollow noopener\" target=\"_blank\">cPanel: Backup<\/a><\/li>\n<li><a href=\"https:\/\/rclone.org\/s3\/\" rel=\"nofollow noopener\" target=\"_blank\">rclone: S3<\/a><\/li>\n<li><a href=\"https:\/\/rclone.org\/commands\/rclone_check\/\" rel=\"nofollow noopener\" target=\"_blank\">rclone: copy and check<\/a><\/li>\n<li><a href=\"https:\/\/restic.readthedocs.io\/en\/stable\/040_backup.html\" rel=\"nofollow noopener\" target=\"_blank\">restic: backup<\/a><\/li>\n<li><a href=\"https:\/\/restic.readthedocs.io\/en\/stable\/060_forget.html\" rel=\"nofollow noopener\" target=\"_blank\">restic: retention<\/a><\/li>\n<li><a href=\"https:\/\/restic.readthedocs.io\/en\/stable\/050_restore.html\" rel=\"nofollow noopener\" target=\"_blank\">restic: restore<\/a><\/li>\n<li><a href=\"https:\/\/docs.oracle.com\/cd\/E17952_01\/mysql-8.4-en\/mysqldump.html\" rel=\"nofollow noopener\" target=\"_blank\">MySQL 8.4: mysqldump<\/a><\/li>\n<li><a href=\"https:\/\/mariadb.com\/docs\/server\/clients-and-utilities\/backup-restore-and-import-clients\/mariadb-dump\" rel=\"nofollow noopener\" target=\"_blank\">MariaDB: mariadb-dump<\/a><\/li>\n<\/ul>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Copy completed cPanel archives and back up application files with restic. Coordinate SQL dumps, scheduling, retention, failure alerts and tested restores.<\/p>\n","protected":false},"author":1,"featured_media":12419,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[184],"tags":[],"class_list":["post-3433","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts\/3433","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/comments?post=3433"}],"version-history":[{"count":9,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts\/3433\/revisions"}],"predecessor-version":[{"id":12421,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts\/3433\/revisions\/12421"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/media\/12419"}],"wp:attachment":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/media?parent=3433"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/categories?post=3433"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/tags?post=3433"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}