This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

[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
Thanks given by:


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

Forum Jump:


Users browsing this thread: 1 Guest(s)