LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-20-2012, 12:59 PM   #1
jim.thornton
Member
 
Registered: May 2007
Posts: 404

Rep: Reputation: 19
Nebie with RSYNC


Okay... I have been using a laptop and a desktop. My laptop was setup first with Linux Mint and then my desktop a few months later also with Linux Mint.

When I setup my desktop, I copied over my Documents folder from my laptop. I have since used my laptop way more than my desktop and also for different tasks. So, my laptop has certain documents changed/updated since I copied it over to my desktop.

I'm starting to find it problematic to have two different computer/documents folders and would like to sync them up.

I was thinking that rsync will do what I need. However right now, what is the first command that I need to run to sync the documents folders. Here is what I would like to accomplish:

1. Copy any missing files from my laptop to my desktop
2. Copy any missing files from my desktop to my laptop
3. Update any files that are the same to the most recently modified file between the two computers.

I've been reading up on rsync a little but am not sure which terminology is correct for what I want.
 
Old 09-20-2012, 01:16 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,559

Rep: Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127
You can accomplish this with two rsync commands. rsync will automatically copy over new files and update files with an old timestamp in one move. So by issuing one rsync from laptop to desktop, you'll accomplish #1 and part of #3, then by issuing an rsync from desktop to laptop you'll accomplish #2 and the rest of #3. Issuing something like the following from the laptop should do it:

Code:
rsync -a ~/Documents desktop:~/Documents  # laptop to desktop
rsync -a desktop:~/Documents ~/Documents  # desktop to laptop
You should create a backup of the Documents directory on both the laptop and the desktop before running this, to make sure it doesn't have any undesired effects.
If you want this to happen automatically in the background, you could set up SSH keys to enable password-less login, and then run it in a cron job ever few minutes/hours.

Note that deleted or renamed files might start to become a problem. This is because when rsync runs, and it sees a local file that does not exist in the destination directory (or vice versa), it has no way of knowing whether this local file is new and should be copied over, or if it's been deleted or renamed on the destination and should therefore be deleted locally as well. This means that if you want to delete or rename a file, you'll need to do it on both the desktop and the laptop at the same time (at least before the rsync commands run again).

Last edited by suicidaleggroll; 09-20-2012 at 01:20 PM.
 
1 members found this post helpful.
Old 09-20-2012, 01:16 PM   #3
camorri
LQ Guru
 
Registered: Nov 2002
Location: Somewhere inside 9.9 million sq. km. Canada
Distribution: Slackware 14.1, 14.2
Posts: 5,187

Rep: Reputation: 526Reputation: 526Reputation: 526Reputation: 526Reputation: 526Reputation: 526
You can accomplish this task with rsync. This is how I back up my user files to my networked storage device.

When I set it up, I set up ssh first. You need sshd running on the destination box. I installed rsync, and a front end called 'grsync'. The front end helped me out a lot. You fill in the source directory, file, etc, and the target directory on the remote system. There are check boxes for Basic, and Advanced options. The nice thing is grsync saves your sync operations. So, if it a dir, or file you regularly need to update, rsync will have a list of your common updates. It made it simple for me.

The nice thing about rsync, is if you make small changes to files, the entire file doesn't get copied, only the changes get copied to the target file. That makes it fast, once the first backups are done. There is an option to 'Simulate' the update. If you have made errors, it will let you know; before you borke up the target. I like it.
 
Old 09-20-2012, 01:22 PM   #4
jim.thornton
Member
 
Registered: May 2007
Posts: 404

Original Poster
Rep: Reputation: 19
How is it possible to only update the changes of a file. For a Word (.doc) file for example, it isn't just a text file, so how would it know how to update the changes of the file without messing up the file structure?

Also... The -a option, isn't that for archive? Not sure what that does. Finally, should I do -r as well to ensure all of the subdirectories are also synced?
 
Old 09-20-2012, 01:25 PM   #5
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,559

Rep: Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127
Quote:
Originally Posted by jim.thornton View Post
Also... The -a option, isn't that for archive? Not sure what that does. Finally, should I do -r as well to ensure all of the subdirectories are also synced?
Yes, -a stands for archive, but all it is is a shortcut for other commonly used flags, namely -rlptgoD

-r = recursive
-l = copy symlinks as symlinks
-p = preserve permissions
-t = preserve modification times
-g = preserve group
-o = preserve owner
-D = preserve device files and special files
 
Old 09-20-2012, 01:40 PM   #6
JaseP
Senior Member
 
Registered: Jun 2002
Location: Eastern PA, USA
Distribution: K/Ubuntu 12.04/14.04, Scientific Linux 6.3/6.4, Android-x86, Pretty much all distros at one point...
Posts: 1,799

Rep: Reputation: 157Reputation: 157
If you want the ease of a graphical setup, consider using grsync. Also, you should use anacron instead of cron, for the rysnc job, as a laptop is unlikely to be on 24/7... Actually, and more properly, use cron to run an anacron job to do the backups,... That way you can specify they get done if the system was off, and periodically check that they were run if the system was active... When the system boots, anacron will be there to run a missed job for you, if you have it set that way...
 
Old 09-20-2012, 01:40 PM   #7
camorri
LQ Guru
 
Registered: Nov 2002
Location: Somewhere inside 9.9 million sq. km. Canada
Distribution: Slackware 14.1, 14.2
Posts: 5,187

Rep: Reputation: 526Reputation: 526Reputation: 526Reputation: 526Reputation: 526Reputation: 526
Quote:
How is it possible to only update the changes of a file. For a Word (.doc) file for example, it isn't just a text file, so how would it know how to update the changes of the file without messing up the file structure?
How it works, I can not comment on. I suggest you go her -->http://rsync.samba.org/ there is a lot of good info, examples, doc, and FAQ etc.
 
Old 09-20-2012, 01:41 PM   #8
jsaravana87
Member
 
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 558
Blog Entries: 5

Rep: Reputation: Disabled
#Its incremental backup : most recently modified file between the two computers.

These command seems to backup only the recent made changes from source to destination folder

# rsync -zavi root@ipadress:/source /destination
 
Old 09-20-2012, 02:15 PM   #9
jim.thornton
Member
 
Registered: May 2007
Posts: 404

Original Poster
Rep: Reputation: 19
That's awesome... Thanks for the help!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
nebie help watmonki Slackware 4 10-29-2005 12:03 AM
How do I Copy modual in to kerral?? (more of a nebie question) msg4real Linux - Hardware 0 02-24-2005 11:56 PM
Nebie Questions- Partition, Format, Dual Boot Zychior Linux - General 3 09-13-2004 05:58 PM
Java on Debian - Nebie HOWTO rikkulinux Debian 5 10-17-2003 02:32 AM
Java on Debian - Nebie HOWTO rikkulinux Programming 6 10-15-2003 09:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration