Backup using RSYNC 24.04

From ScottWiki
Revision as of 02:55, 25 March 2024 by Wikiadmin (talk | contribs) (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%.*}_${...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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