Bash: File Server Hourly Backup Script

Administration, Info.Tech, Linux System Administration Add comments

Been 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…


cd /backup/

DATE=$(date "+%Y%m%d%H%M%S")


# 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.

Comments are closed.

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in