Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

If there's any change in ~/mydir, I want to copy it to ~/someotherdir/mydir_revisions/04-02-2013 (which is today's date). It should continue to copy to this same directory for 1 week. Thereafter, it should create a new directory (~/someotherdir/mydir_revisions/04-09-2013, which is that day's date and continue using that directory for a week). These backups would continue indefinitely, always utilizing a particular date for a whole week before updating the date.

If it matters, I'm using Archlinux and copying to a different filesystem. How can I do this with incron or any other recommended package?

share|improve this question
Are you comfortable with any scripting language? Bash or Perl or similar? – terdon Apr 3 '13 at 0:07
I'd like to suggest using inotifywait for this; have used it on several occasions in the past, works a treat. – tink Apr 3 '13 at 0:08
@terdon, I prefer Python, but I'd be willing to learn Bash if need-be – Raj Apr 3 '13 at 0:09
Which ever route you're going to go down, I'd like to point out that neither incron, inotifywait or either of the two python implementations I'm aware of will stand up recursive watches for newly created subdirectories automatically - just a small caveat. – tink Apr 3 '13 at 2:18
Have you considered using a version control system like git? You'd get a record of the changes too. – parkydr Apr 3 '13 at 8:39

Depending on your distribution, there is the package incrond.

What this package does is, it receives filesystem events from the kernel via inotify.

Your setup would be something as:

/path/to/monitored/directory IN_MODIFY /path/to/script/to/execute

Let's say you have the following script in $HOME/, with does the following:

WEEK_OF_YEAR=`date +"%W"`
cp -ar $HOME/mydir /other/dir/mydir_revisions/$WEEK_OF_YEAR

What this script does, is to copy the full contents of /path/to/monitored/directory to /other/dir/mydir_revisions/13 if it were to run today (02/04/2013 it's in the 13th week of the year)

It isn't the full requirement of yours, but solves your problem with some degree of reliability.

share|improve this answer
I'm aware of that package. I'm looking to do something more specific than copying to a directory upon change. I want to include a date, as described in the question. – Raj Apr 3 '13 at 0:15
@Raj date supports alot of options (eg. +%Y-%m-%d). Also, there is likely a Python inotify interface-module. – Ярослав Рахматуллин Apr 4 '13 at 3:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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