Email or username:

Password:

Forgot your password?
Alex Schroeder

I'm surprised to find how useful this is for a quick local backup of your working directory.

#!/usr/bin/bash
d=$(basename $(pwd))
t=$(date --iso-8601)
echo Creating a snapshot of $d in ../$d-$t
rsync --link-dest "../$d" --archive . "../$d-$t/"

if you're in directory bla/foo and run it, you'll get a sibling directory bla/foo-2023-11-20 with links pointing to the originals in bla/foo while you don't edit them. Doesn't take a lot of space, gives you the peace of mind you need before running that global search-and-replace operation on all your files.

1 comment
Ed Davies

@alex Doesn't this depend on how you “edit” the files? If you use a normal text or image editor then, yes, it'll probably write a fresh file when you save which will be separate from the linked version but if you do something like update a sqlite database then it'll update in place and both “versions” will be updated. Worth bearing in mind.

Go Up