rsync ssh syntax?
-
I know the guvnr is going to write a tut on this but, in the meantime, can anyone tell me the syntax for getting rsync to work over ssh?
I want to run this from my local machine, have it go to the vps, log in, grab the directories, transfer them to my local machine and delete anything from local that isn't on the vps.
After having Googled this for hours the other day, I came up with the following:
rsync -ave --times --delete ssh -p 54321 vpsuser@12.34.56.78:/home/vpsuser/testdir /home/localuser/Desktop/
(Of course, I used the correct usernames, ip and port number)
It doesn't work. The error is: syntax or usage error.
What's wrong with the code?
Posted 1 year ago # -
OK, I figured it out. Here's how it's done.
rsync -e 'ssh -p 54321' -av --times --delete vpsuser@12.34.56.78:/home/vpsuser/testdir /home/localuser/Desktop/
You can use other options but the ones used here mean:
-e = specify rsh replacement (in this case ssh)
-a = archive mode
-v = increase verbosity
--times = preserve times
--delete = delete files that don't exist on the sending sideBe careful how you use the --delete option. It will delete files that don't exist on the sending side so if you want to save files locally that you have already deleted remotely, don't use delete.
How you use the / in the paths is important.
When using / at the end of source, rsync will copy the content of the last folder.
When not using / at the end of source, rsync will copy the last folder and the content of the folder.When using / at the end of destination, rsync will paste the data inside the last folder.
When not using / at the end of destination, rsync will create a folder with the last destination folder name and paste the data inside that folder.Posted 1 year ago # -
The command works but it's not perfect. Some files don't transfer and trigger Permission denied errors.
I guess the script need to assume root powers on the vps?
I created a simple bash script to run several commands but I can't get it to run from crontab as user or root.
Looking forward to that tut :)
Posted 1 year ago # -
Baranby, i'm curious to know what you're using rsync for... are you rsync servers to set up load balancing? or for another reason? i'm actually looking to learn more about load balancing.
Posted 1 year ago # -
I'm using it to back up various directories from the vps to my local back up hard drive.
Posted 1 year ago # -
aye .. good plan Mr B .. here's an idea:-
REMOTE
- cron a daily mysqldump db backupLOCAL
- cron (or Wins eq) the db dump to local backup using scp/rsync
- cron web files using rsyncREMOTE
- second cron remotely to delete the mysqldump for security reasons, say qtr-hour after the local cron brought the db down (really really)Variations:-
set your backup system to cron sequential daily backups into local folders (M,T,W,T,etc) .. and have a weekly, non-sequential backup too.
.. that's a whole lotta backup but, one day, you may just remember this thread!
Posted 1 year ago #
Reply
You must log in to post.
Want HTML?
a blockquote code em strong ul ol liPlace code between backticks `codeHere`
You've got it.
