Cron Job

Mourad Meziou

New Member
Apr 3, 2019
9
0
1
49
Hello,
I need to create a cron Job to copy rhe backup of VM from local server to an FTP location.
Anyone can help ?

Thanks in advance
 
hi,

does it have to be FTP? if you have a NFS or SMB share instead, you can add that as a storage and then use the backup jobs function: Datacenter -> Backup -> Add

this would make the cronjob for you in /etc/pve/vzdump.cron

otherwise you can also write a small script to do this;

1. run vzdump for selected VM
2. copy the resulting backup file over ftp to your target

and if you want to call this every day for example, then you can add something like this in crontab:
0 0 * * * /path/to/your/script will run it at midnight every day
 
Hello,
Thank you for your replay
For example if my backup path is : /backup-CCI/dump/
The script will be :
0 0 * * * /backup-CCI/dump/
did you have an exemple of a script that do the job (Copy the VM from /backup-CCI/dump/ to ftp location)
Thanks in advance
 
The script will be :
0 0 * * * /backup-CCI/dump/
no, you need to create a script and give the path to it in cron.

for example if your script is /root/backup_and_send_vm.sh, then your cronjob would be
Code:
0 0 * * * /root/backup_and_send_vm.sh

and the contents of /root/backup_and_send_vm.sh would be something like:
Code:
#!/bin/bash
vzdump 100 # make a backup of VM 100
backupfile=$(find /var/lib/vz/dump -mtime -1 -name '*qemu-100-*.vma') # find the backup file
echo "found backup file in $backupfile"
# copy to FTP left as exercise :)
 

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!