LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   SCP or rsync? (https://www.linuxquestions.org/questions/linux-general-1/scp-or-rsync-855167/)

centosfan 01-09-2011 09:16 AM

SCP or rsync?
 
What do you use for transferring files from one to another server?So far i was using scp command,but i see rsync function basically same,except i heard how rsync copies files in realtime.Also is it possible to insert password in command(for automated backup purposes) or that can be arranged only by using ssh keys?

kbp 01-09-2011 09:24 AM

I prefer rsync as it's more flexible, don't expose the password - distribute the keys

choogendyk 01-09-2011 03:25 PM

Each has its own place. You haven't described your situation. I use a variety of tools depending on the situation. If I'm just looking to copy one or a few files or a small directory, I'll use scp, just because it is so simple and works. If I'm copying a large directory that's going to take a long time and I don't want to lose time if there are any problems or failures, I'll do it with rsync. Then I can just do the same command again, and it will clean up any differences much more quickly. There are also times when I'll use gnutar or ufsdump (I'm on Solaris systems mostly). I also have some scripts that pipe the results of a find to cpio.

centosfan 01-09-2011 07:07 PM

Well what i plan to do is to set up automatic backup with cron of databases and home files.For databases i would simply copy /var/lib/mysql directory.

choogendyk 01-09-2011 08:02 PM

If you are backing up databases, simple copies or rsync may not give you consistent backups. Take a look at http://dev.mysql.com/doc/refman/5.1/...p-methods.html. You could dump your databases to a different directory and then back that up.

Also, without additional thought and effort, using scp or rsync to simply copy a directory out will leave you with only one backup. If you happen to pull some kind of snafu late in the evening, and then your backup runs, when you get up in the morning, you will find that both your primary data and your backup are snafu'd (because the backup copied the messed up stuff and overwrote the backup with it).

So, if you are thinking about using rsync, take a look at doing snapshot style incremental backups with it. The classic description of how to do this is http://www.mikerubel.org/computers/rsync_snapshots/. This idea has been developed into a number of different backup packages, including http://rsnapshot.org/, http://www.ubuntugeek.com/flyback-sn...-on-rsync.html, http://rdiff-backup.nongnu.org/acknowledgments.html, & others. Google could keep you busy for a while investigating alternatives if you wanted to do that.


All times are GMT -5. The time now is 10:38 AM.