Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am a beginner with the Unix system so please bear with me if this sounds noobish.

The most common way to use rsync to do an incremental backup is to do it like this

rsync -av --delete <source> <destination>

Is there a way to do it in such a way that you compare directory1 with directory2 but then store the output in directory3?

Basically, what I want is to have a series of daily incremental backups with one full backup to use as the base.

So if I have these folders and today is 20130103,

/folder/to/back/up <-- source
/backup/base <-- base
/backup/20130101 <-- incremental
/backup/20130102 <-- incremental

I want to compare /folder/to/back/up with /backup/base and store the result in a new folder, /backup/20130103.

share|improve this question

closed as off topic by EEAA, Ward, Dennis Kaarsemaker, RolandoMySQLDBA, mdpc May 9 '13 at 16:45

Questions on Server Fault are expected to relate to server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

It sounds like you actually want rsnapshot, which is a wrapper around rsync and a couple other tools. It automates building an incremental backup structure that is very close to what you're wanting.

share|improve this answer
I will try to look into this. As I said, I am just a newbie in Unix. When I googled for answers, the most common suggestion is to use rsync so I went with it. – arvinsim May 9 '13 at 3:22
UPDATE: I can't use rsnapshot since the machine where I plan to implement does not have it and I don't have permission to install it. – arvinsim May 9 '13 at 3:31
@arvinsim - Well, in that case, this question is off-topic, as you are not the administrator of the system in question. – EEAA May 9 '13 at 3:43
I was not aware that I needed to be a sysadmin to post here. If that is true, I will move this to stackoverflow. – arvinsim May 9 '13 at 3:47
@arvinsim - the FAQ states as much. Anyway, Unix & Linux would be a better home than SO. I'll vote to migrate over there - please don't re-post. – EEAA May 9 '13 at 3:48

The rsync flags to look at are

--compare-dest=DIR      also compare received files relative to DIR
--copy-dest=DIR         ... and include copies of unchanged files
--link-dest=DIR         hardlink to files in DIR when unchanged

For example:


The basic principle of that article ("Time Machine for every Unix out there") has been implemented in many different ways by many different programs, rsnapshot being yet another of them.

Dirvish deserves special mention (the original author contributed the --link-dest patch to rsync); it's a Perl backup system utilising rsync and hardlinks (similar to rsnapshot) with datestamped destination folders, variable expiry rules, exclude rules etc.; since it uses hardlinks, every backup appears in the filesystem as a "full backup" but only the "incremental" changes are copied.

If you have (or can install) Perl, I'd strongly suggest Dirvish for what you want.

share|improve this answer
so basically, set --link-dest to /backup/base, <source> to /folder/to/back/up and <destination> to /backup/20130103? – arvinsim May 9 '13 at 5:08
@arvinsim Most likely yes; I'll add some examples to my answer. – Andrew May 9 '13 at 6:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.