This easy backup script creates a
.tar.gz for a certain folder. The script can be used to backup a full folder once or scheduled. The date the backup is made is added to the final file.
#!/bin/bash dir="xxx" srcdir="/data/$dir/" trgdir="/data/backup/$dir/" date=$(date "+%Y-%m-%d %H;%M") #format: yyyy-mm-dd hh;mm fn="$dir $date.tar" tar -czf "$trgdir$fn" $srcdir gzip "$trgdir$fn"
Save the script and store it wherever you want. You can add it to your crontab (
crontab -e) to run on a schedule.
Be aware: this script is limited, it backups the whole folder and doesn’t use an incremental backup. Usually you would use a full backup and incremental backup together.