Backup using RSYNC 24.04: Difference between revisions
Jump to navigation
Jump to search
(Created page with "Now we create a little script to backup via RSYNC nano /srv/backup/backup.sh You will need to create the appropriate backup locations for the script to use. <pre> #!/bin/bash # ===================================================================== # Script to Rsync backup # # V1.00 2024-03-20 Initial Release (Scotty) # ===================================================================== source_file="backup" date=$(date +"%Y-%m-%d") new_filename="${source_file%.*}_${...") |
No edit summary |
||
Line 26: | Line 26: | ||
</pre> | </pre> | ||
You can now add a cron job to run the script. | |||
crontab -e | |||
Add the following lines | |||
00 03 * * 7 /srv/backup/backup.sh | |||
00 03 * * 3 /srv/backup/backup.sh | |||
This will run a backup on Sunday morning and Wednesday Morning at 03:00 am |
Latest revision as of 02:57, 25 March 2024
Now we create a little script to backup via RSYNC
nano /srv/backup/backup.sh
You will need to create the appropriate backup locations for the script to use.
#!/bin/bash # ===================================================================== # Script to Rsync backup # # V1.00 2024-03-20 Initial Release (Scotty) # ===================================================================== source_file="backup" date=$(date +"%Y-%m-%d") new_filename="${source_file%.*}_${date}.log" rsync -azAXPH --stats --delete --exclude='/swap.img' --exclude='/srv/*' --exclude='/dev/*' --exclude='/proc/*' --exclude='/sys/*' --exclude='/tmp/*' --exclude='/run/*' --exclude='/mnt/*' --exclude='/media/*' --exclude='/lost+found/' / /srv/backup/cronbackup/backup_root > /var/log/backup/$new_filename rsync -azAXPH --stats --delete /srv/data/ /srv/backup/cronbackup/backup_data/ >> /var/log/backup/$new_filename rsync -azAXPH --stats --delete /srv/media/ /srv/backup/cronbackup/backup_media/ >> /var/log/backup/$new_filename # Send a mail the backup has run mail -s "Backup Completed" mark@scottworld.net < /var/log/backup/$new_filename
You can now add a cron job to run the script.
crontab -e
Add the following lines
00 03 * * 7 /srv/backup/backup.sh 00 03 * * 3 /srv/backup/backup.sh
This will run a backup on Sunday morning and Wednesday Morning at 03:00 am