Remote Offsite Backup with Rsync

Shell Script to Backup Websites and Databases from your VPS (Digital Ocean, Linode, AWS, Vultr). Be sure to edit the configuration options at the beginning of the script to match your environment prior to executing.

Usage:

  1. Pull up a terminal or SSH into the target server.

  2. Logon as root

sudo -i
  1. Download the script(s).
wget https://raw.githubusercontent.com/clusterednetworks/rsync-offsite-backup/master/rsync.server.ssh.key.sh
wget https://raw.githubusercontent.com/clusterednetworks/rsync-offsite-backup/master/rsync.server.ssh.password.sh
  1. Edit the configuration options at the beginning of the script to match your environment prior to executing.
    #----------------------------------------
    # OPTIONS
    #----------------------------------------
    # connection info
    REMOTE_HOST=yourserver.yourdomain.com
    REMOTE_USER=your-login-user
    REMOTE_PORT=22

path to private key

KEY=/home/??/

path to backup to files to

LOCAL_PATH=/home/backup/backuptest

path to pull the files from

REMOTE_PATH=/home/backup/backuptest

  1. Make the script executable
chmod +x rsync.server.ssh.key.sh
  1. Run the script.
./rsync.server.ssh.key.sh
  1. Setup a cronjob to run the script daily/weekly if you choose.
    5 1   * * * /etc/rsync.server.ssh.key.sh >/dev/null 2>&1
    

Posted in Linux Network Admin Tips, Network Security Tips on Dec 24, 2020