C3rd
Bash: File Server Hourly Backup Script
Posted: 11 May 2016, 3:04am - WednesdayBeen creating bash backup scripts but every time I create for the new server, I forgot the commands and research again. This time, I'm gonna save it in my blog so that I will search it in one place. Hehehe...
#!/bin/bash cd /backup/ DATE=$(date "+%Y%m%d%H%M%S") BACKUPNAME="jdrive_$DATE" mkdir $BACKUPNAME # find -mtime -1 | xargs cp -t --parents "$BACKUPNAME/" find /jdrive/ -mmin -60 -exec cp --parents '{}' "$BACKUPNAME/" \; tar -zcvf "ibackup/$BACKUPNAME.tar.gz" "$BACKUPNAME/" rm -rf "$BACKUPNAME/" # file and delete all files smaller than the specified filesize find /backup/ibackup/ -name "*.gz" -size -500 -delete # file and delete all files that are older than 45 days find /backup/ibackup/ -mtime +45 -type f -exec rm -rf {} \;Here you go... My home-brewed incremental backup script. We usually use duplicity but it failed us twice. So, we are using now both my home-brewed script and duplicity. Oh! by the way, I used this script for our file server only.