automatically transfer proxmox backup to external disk

Automating Proxmox Backup Transfer

Automating Proxmox Backup Transfer to an External Hard Disk

You can automate the backup transfer process using a cron job that runs every day at 4 AM. This cron job will use the rsync command to copy the backup files from the Proxmox server to the external hard disk, ensuring that only new or modified files are transferred.

1. Mount the External Hard Disk

Ensure that your external hard disk is mounted on a specific directory, for example /mnt/external_backup. You can add an entry in your /etc/fstab to automatically mount the external hard drive on boot:

UUID=<your_disk_uuid> /mnt/external_backup ext4 defaults 0 2
    

Replace <your_disk_uuid> with the actual UUID of your external hard drive. You can find it by running:

lsblk -f
    

2. Create the Cron Job

To create the cron job that will run every day at 4 AM, follow these steps:

  1. Open the cron file for editing:
  2. crontab -e
            
  3. Add the following line to schedule the backup task at 4 AM every day:
  4. 0 4 * * * rsync -av --ignore-existing /path/to/proxmox/backups/ /mnt/external_backup/
            

Explanation of the rsync Command:

Example Cron Job Entry:

0 4 * * * rsync -av --ignore-existing /var/lib/vz/dump/ /mnt/external_backup/
    

This cron job will run at 4 AM every day, copying only new or modified backup files from /var/lib/vz/dump/ (the default Proxmox backup directory) to /mnt/external_backup/ (the external hard disk).

3. Check Cron Job Status

After adding the cron job, you can verify that it's been added by running:

crontab -l
    

This will list all the active cron jobs for the current user.

Conclusion

With this setup, the backup files from Proxmox will automatically be copied to your external hard disk every day at 4 AM. Only files that are not already present on the destination will be transferred, ensuring efficient use of time and storage space.