Linux – CentOS Backup BASH Script

bashcentoslinux

I just wrote this script for backing up everything into a tar.gz file. Does it look okay? How can I get the tar file to transfer itself over to another server after executing? FTP from itself? I'm going to put this script into a weekly cron.

#!/bin/bash

rm ~/backup.tar.gz #removes old backup
BACKUP_DIRS=$HOME #$HOME is builtin, it goes to /home/ and all child dirs
tar -cvzf backup.tar.gz $BACKUP_DIRS

# run tar -zxvf to extract backup.tar.gz

Best Answer

FTP is the devil. SCP with RSA keypairs is a good way to move the files securely from server to server. As for the script, it looks fine.