Sentora Support Forums

Full Version: [How to] [Ubuntu] Send backup files to remote server using rsync
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
First we need to make a RSA key to the remote server 

STEP 1

Code:
ssh-keygen -t rsa

STEP 2

Once you have entered the Gen Key command, you will get a few more questions:

Code:
Enter file in which to save the key (/home/demo/.ssh/id_rsa):

You can press enter here, saving the file to the user home (in this case, my example user is called demo).

Code:
Enter passphrase (empty for no passphrase):

Step 3

Now we copy the rsa key to the remote server

Code:
ssh-copy-id root@111.222.333.444

Now we test if is works

Code:
SSH root@111.222.333.444
If you don’t need to enter password it Works

Now the Rsync script

Step 1

Code:
Nano /var/script/backup.sh

Add this

Code:
#!/bin/bash ############################### # Some settings ############################### # rsync options DEST=root@111.222.333.444:/patch/to/the/folder/to/save/files/ SRC=/var/sentora/hostdata/* OPTIONS="-e ssh --delete --progress -azvhHS --numeric-ids --delete-excluded" EXCLUSIONS=" --exclude public_html" ############################### # The real work ############################### # Do the actual backup rsync $OPTIONS $EXCLUSIONS $SRC $DEST

If you add --remove-source-files in OPTIONS it delete the files after upload on source server

SETP 2

Add crontab

Code:
Crontab –e

Add the line

Code:
@daily bash /var/script/backup.sh

This will at the script at midnight