[TUTORIAL] Tutorial: Backup local_storage to offsite_storage using SMB (CIFS)

TheHellSite

Active Member
Mar 4, 2020
78
53
38
Hello,

I have a single PVE node with several VMs and lots of backups. In order to improve redundancy I wanted to mirror the local storage to a cloud provider.
As I didn't want to install any additional 3rd party tools I decided to go with rsync which comes by default with PVE.
For me the best solution was to first sync the local storage to the offsite_storage on my TrueNAS and from there to my cloud provider.
Since there was no good guide anywhere in the Proxmox forums I thought I would just share my tutorial.

I won't get into detail on how to set up the cloud sync task on TrueNAS as there are plenty of guides and a very good documentation.
https://www.truenas.com/docs/hub/tasks/scheduled/cloudsync/

Backup local_storage to offsite_storage on PVE (f.e. cifs)

On your NAS / Server
  1. Create an SMB/CIFS share called "offsite_storage" and create a new SMB user (f.e. proxmox) that has r/w access to that share.
On your PVE
  1. Mount the "offsite_storage" share: Datacenter --> Storage --> Add --> CIFS
  2. Create a new cron job using SSH+nano or using WinSCP / FileZilla. Use whatever you prefer, this guide will SSH + nano.
  3. SSH into your PVE.
  4. nano /etc/cron.d/offsite_backup
  5. Insert the config below (adjust the time and command to your needs) and save the file.
    Code:
    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    # sync backups to remote storage daily at 4 am.
    #                                  local_storage          remote_storage
    0 4 * * * root rsync -hrt --delete /mnt/pve/data_ssd/dump /mnt/pve/offsite_backup/
    Attention: There has to be one blank line at the end of the file otherwise cron will refuse to run the job.
  6. Restart cron: systemctl restart cron
  7. Check that cron started without any errors: systemctl status cron
    Code:
    root@PVE:/mnt/pve/data_ssd# systemctl status cron
    ● cron.service - Regular background program processing daemon
       Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
       Active: active (running) since Fri 2021-03-19 13:07:28 CET; 33s ago
         Docs: man:cron(8)
    Main PID: 17371 (cron)
        Tasks: 1 (limit: 4915)
       Memory: 652.0K
       CGroup: /system.slice/cron.service
               └─17371 /usr/sbin/cron -f
    
    Mar 19 13:07:28 PVE systemd[1]: Started Regular background program processing daemon.
    Mar 19 13:07:28 PVE cron[17371]: (CRON) INFO (pidfile fd = 3)
    Mar 19 13:07:28 PVE cron[17371]: (CRON) INFO (Skipping @reboot jobs -- not system startup)
  8. Done. The cron job should now run daily at 4 am.

Notes
Testing the cron job
In order to test the behaviour of the command do the following.
  1. Change the timer of the cronjob to run it every 15 minutes: 15 * * * *
  2. Restart cron: systemctl restart cron
  3. Check that cron started without any errors: systemctl status cron
  4. If the command does what is expected revert the changes to use the final command.

Kind Regards
TheHellSite
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!