LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 07-27-2015, 11:38 AM   #1
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Rep: Reputation: 103Reputation: 103
understanding rsync --link-dest


I was checking out this link http://www.howtogeek.com/175008/the-...ta-with-rsync/ and I wanted to understand exactly how --link-dest works in that case. This is the command that I found on the site:

Quote:
rsync -avzhPR --chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r --delete --stats --log-file=~/backup/rsync-`date +”%F-%I%p”`.log --exclude-from '~/exclude.txt' --link-dest=/home/geek2/files/`cat ~/backup/time2.txt` -e 'ssh -p 12345' /home/geek/files/ geek2@10.1.1.1:/home/geek2/files/`date +”%F-%I%p”`/
What I'm actually interested in knowing is, where does /home/geek2/files/`cat ~/backup/time2.txt` exist? Locally or on the 10.1.1.1?

If it's local, then for me it doesn't make too much sense. The idea is to create backups ON the server and create them relative to the previous backups still on the server. So how does it work? (I understand that rsync uses hard links and that's the idea of link-dest, so that part is more or less clear)
 
Old 07-27-2015, 01:19 PM   #2
mralk3
Slackware Contributor
 
Registered: May 2015
Distribution: Slackware
Posts: 1,904

Rep: Reputation: 1053Reputation: 1053Reputation: 1053Reputation: 1053Reputation: 1053Reputation: 1053Reputation: 1053Reputation: 1053
I only briefly glanced at the tutorial you linked.

It appears that the time.txt is located on the local machine and is copied to the remote machine later on.

All of these commands are in fact doing what you are expecting. time.txt and time2.txt were created to track the snapshot date and time.

The commands you are running require that you understand the documentation of rsync, first. Just running commands is going to be plain confusing if you do not read the docs.

Code:
man rsync
 
Old 07-27-2015, 01:36 PM   #3
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Original Poster
Rep: Reputation: 103Reputation: 103
Quote:
Originally Posted by mralk3 View Post
I only briefly glanced at the tutorial you linked.

It appears that the time.txt is located on the local machine and is copied to the remote machine later on.

All of these commands are in fact doing what you are expecting. time.txt and time2.txt were created to track the snapshot date and time.

The commands you are running require that you understand the documentation of rsync, first. Just running commands is going to be plain confusing if you do not read the docs.

Code:
man rsync
Would it be possible to actually answer my question specifically? I am sure that wouldn't be too much to ask.
 
Old 07-27-2015, 02:07 PM   #4
mralk3
Slackware Contributor
 
Registered: May 2015
Distribution: Slackware
Posts: 1,904

Rep: Reputation: 1053Reputation: 1053Reputation: 1053Reputation: 1053Reputation: 1053Reputation: 1053Reputation: 1053Reputation: 1053
Quote:
Originally Posted by mralk3 View Post
It appears that the time.txt is located on the local machine and is copied to the remote machine later on.
I did answer your question to the best of my knowledge. I am not going to read the documentation for you and spell it out though.
 
Old 07-27-2015, 03:00 PM   #5
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Original Poster
Rep: Reputation: 103Reputation: 103
Ok, I hadn't read your answer correctly.


First of all, I understand everything that is being used in that tutorial. That's not a problem. The rsync manual pages are of no help in this case.

So I have a client whose files I want to backup on that server. As I understand, --link-dest refers to the previous backup that was already made and creates hardlinks relative to that previous backup and adds any new/changed files. That much is clear. What I don't understand is why doesn't --link-dest refer to a path ON the server, instead of on the local machine? Indeed, I may not understand exactly how link-dest option works. Why does it compare it to something on the local machine, instead of with a previous backup made on the server? I hope my question is clear enough.

Thanks

Last edited by vincix; 07-27-2015 at 03:10 PM.
 
Old 07-27-2015, 05:30 PM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,783

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
It does refer to a path on the server, but the way you have it coded could be a problem. Your local shell is going to expand the `cat ~/backup/time2.txt` substitution and pass the result to the rsync process on the server. Whether the result of that expansion makes sense on the server is another matter. If you really wanted to get the content of a time2.txt file from the server, you would need to do it another way, either by copying that file to the local machine or by executing the cat command on the server with something like:
Code:
--link-dest=/home/geek2/files/`ssh geek2@10.1.1.1 cat backup/time2.txt`
 
1 members found this post helpful.
Old 07-27-2015, 05:48 PM   #7
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Original Poster
Rep: Reputation: 103Reputation: 103
Quote:
Originally Posted by rknichols View Post
It does refer to a path on the server, but the way you have it coded could be a problem. Your local shell is going to expand the `cat ~/backup/time2.txt` substitution and pass the result to the rsync process on the server. Whether the result of that expansion makes sense on the server is another matter. If you really wanted to get the content of a time2.txt file from the server, you would need to do it another way, either by copying that file to the local machine or by executing the cat command on the server with something like:
Code:
--link-dest=/home/geek2/files/`ssh geek2@10.1.1.1 cat backup/time2.txt`
Thanks for the explanation.
So if I wanted something easier - if I had a backup and then I wanted only another single differential backup, after some files changed, what would the correct command be, ignoring in this example now the command expansions?

For instance, if I'd like to backup my home directory and have another differential backup on my server under the folder /backup/home2.

Code:
rsync -av --link-dest=/backup/home /home/user server:/backup/home2
Would that suffice as a basic one-time differential backup (after the initial one)? As I understand from what you've said, --link-dest=/backup/home refers to the path on the server (or more generally, on the destionation side).

And a second question: I'm trying to back up files from a Mac OS and the ownership of the files is different from the ones on the server (meaning that it changes the owner and the group when the files are synchronized on the server).

That does automatically mean that rsync will not create hardlinks, but will copy the files entirely? And is there a way to avoid this without having to create an analogous user/group on my linux server? Maybe break up the -a option and omit the -p (perms)? There must be an easier way, right? I'd prefer using rsync and not some other tool that works on top of rsync, as I'd really like to understand exactly how rsync works.

[later edit]
I did get it to work on my mac without having to bother with the ownership. So it did work like that directly.

Thank you for your answer.

Last edited by vincix; 07-27-2015 at 06:29 PM.
 
  


Reply



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
rsync --link-dest not working? sammckee Linux - Software 4 05-10-2014 12:46 PM
rsync in conjunction with the --link-dest option does not output deleted files maikelmeyers Programming 3 01-04-2013 05:06 PM
Questions about rsync and '--link-dest' flag donnaaparis Linux - General 1 07-14-2011 12:55 PM
rsync log format option (--link-dest) rbalaa Linux - Server 2 04-03-2010 09:53 AM
Problem using rsync for backups: link-dest JosephS Linux - Software 0 02-21-2008 07:43 AM

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

All times are GMT -5. The time now is 11:48 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
Open Source Consulting | Domain Registration