Using unison just for backups
These are working notes. I am not guaranteeing that using unison for this purpose is a good idea
I consider synchronization an extension of the making backups problem, so it occurred to me that I could use unison to manage the backing up of my laptop to an external drive.
i.e. every week or so copy the files that have changed to a backup.
In my example case, I back up my temporary directory to my F: drive
C:\moreprgs\unison>unison.exe c:\moreprgs\unison\a.tmp f:\a-backup -backups
- rather than delete old copies, -backups causes unison to move them to an different file. This means that you could end with up to -maxbackups (default=2) three copies of each file.
So I created a directory structure on my C: drive and repeatedly edited and synchronized my barsteward file:
C:\moreprgs\unison>dir a.tmp
Volume in drive C is TPATMRJCDOTCOM_C
Volume Serial Number is FCB2-E47D
Directory of C:\moreprgs\unison\a.tmp
09/08/2005 22:17 <DIR> .
09/08/2005 22:17 <DIR> ..
22/07/2005 20:24 7 b.txt
09/08/2005 22:21 35 barsteward
22/07/2005 20:44 <DIR> d
09/08/2005 21:48 0 foo
3 File(s) 42 bytes
3 Dir(s) 18,231,308,288 bytes free
After doing so I end up with:
C:\moreprgs\unison>dir f:\a-backup
Volume in drive F has no label.
Volume Serial Number is ECCF-391A
Directory of f:\a-backup
09/08/2005 21:18 <DIR> .
09/08/2005 21:18 <DIR> ..
09/08/2005 21:18 7 b.txt
09/08/2005 21:18 <DIR> d
09/08/2005 21:48 0 foo
09/08/2005 22:17 0 barsteward..002..unison.bak
09/08/2005 22:19 17 barsteward..001..unison.bak
09/08/2005 22:21 35 barsteward
5 File(s) 59 bytes
3 Dir(s) 876,462,080 bytes free
C:\moreprgs\unison>unison.exe -ui text -batch c:\moreprgs\unison\a.tmp f:\a-bacup -backups
Contacting server...
Looking for changes
foo
Reconciling changes
a.tmp a-backup
changed ----> barsteward
a.tmp : changed file modified at 22:40:19 on 9 Aug, 2005 size 40
read-write
a-backup : unchanged file modified at 22:21:08 on 9 Aug, 2005 size 35
read-write
Propagating updates
UNISON started propagating changes at 22:40:44 on 09 Aug 2005
[BGN] Updating file barsteward
from c:/moreprgs/unison/a.tmp
to f:/a-backup
[END] Updating file barsteward
UNISON finished propagating changes at 22:40:45 on 09 Aug 2005
Saving synchronizer state
Synchronization complete (1 item transferred, 0 skipped, 0 failures)
Notes:
- Unlike the ReadWriteOfflineWiki possibility of ReplicationUsingUnison that requires multiple machines, backup typically doesn't. (If yours does, unison can handle that too).
- As long as I don't ever alter the contents of my external drive there are no changes coming back. Unison has a -prefer flag that could make this
- I have been doing my experiments without a set of unison profiles, instead specifying stuff on the command line. I expect to change my method as I understand more about unison.
--
MartinCleaver - 10 Aug 2005
See also
SyncContrib
--
MartinCleaver - 26 Nov 2005
This looks pretty good - have been playing around getting my laptop to sync via
OpenSSH to my Dreamhost webserver for backup purposes. As long as you use the
backups option in the preferences, it's possible to keep old versions around, protecting against the problems of deleting or overwriting files by mistake, and then syncing (which will correctly delete the file or copy the overwritten one). Important in these days of Nyxem viruses (
Google:nyxem+virus+overwrite
)...
I now have Unison syncing working nicely between Windows and Linux (Dreamhost), including use of
ssh-agent to enable unattended backups. The
backup feature using centralised backups has a few issues with subdirectories but other than that everything's working well. Unison is a very useful tool, and once you have a working setup it's not hard to create profiles to back up additional sets of files. I'm also using it to sync data files between a laptop and desktop, via the web host as recommended and to create an off-site backup.
--
RichardDonkin - 05 Feb 2006