oncode
6/3/2014 - 10:17 AM

Create a backup file on linux server with the tar command. Use crontab to execute it weekly.

Create a backup file on linux server with the tar command. Use crontab to execute it weekly.

# Create compressed  files backup
# -z uses compression
# -c creates backup file
# -v for more verbose output
# -p preserves permissions
# -f name/location of backup file
# --directory sets root backup directory
# --exclude exludes a subdirectory from the backup
tar -zcvpf /backup/files/`date +"backup_%d-%m-%y"`.tar.gz --directory=/files .

# Restore backup
# tar -zxvpf /backup/files/xxx.tar.gz
# Use crontab -e and append the content of this file

# Execute backup every monday 10:00
0 10 * * 1 bash /backup/files.sh