[How to] [Ubuntu] Send backup files to remote server using rsync
#1
[How to] [Ubuntu] Send backup files to remote server using rsync
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
Sentora 1.0.3 on [Image: DO_Logo_Horizontal_Blue-3db19536.png]

-= Github =-  -= My Repo =-

My Modules
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Upgrade to Ubuntu 16.04 from 14.04 HogensHero 8 33 ,937 07-18-2020, 03:13 AM
Last Post: dycott78
Ubuntu: How to Enable tls/ssl in proftpd Diablo925 2 14 ,257 04-21-2020, 03:35 AM
Last Post: iraqiboy90
Ubuntu 18.04 or 20.04 Kangarooo 1 8 ,038 03-20-2020, 11:39 AM
Last Post: Jettaman

Forum Jump:


Users browsing this thread: 1 Guest(s)