Setup your system for an easy backup

From Andreida

How to setup your system

You want as much data as possible in one directory and you want that directory to contain ONLY data which goes into your backup. Not one temporary or cache file should be inside that directory. We will call this directory "data" from now on.

This "data" directory might contain your MP3s, your videos, your pictures, your virtual machines, your Subversion or Mercurial repositories and your installers for tools which you don't want to download again.

  • You will never work directly in "data".
  • You will add files from "data" to your media player, install tools from "data" or have your svn working directories access the server repository in "data".
  • But Mercurial for example will be different.
  • You will have a "work" directory somewhere.
  • Here you will do your work.
  • Here you will checkout svn or Mercurial.
  • Here you will have a downloads directory (Change the OS download directory here).

If you are using Mercurial, you will have a server repository in "data" which has an empty working directory ("hg update null") and you will work with the clone in "work".

If using Windows, you will have a shortcut to a script in %USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\ which will commit (for svn) or commit+push (for Mercurial) for certain checked out projects. Of course NOT for your development projects. If you do it this way and boot your computer daily, you will have a daily backup of your changes. But only the difference. You make no changes, no extra backup data. Just how svn/Mercurial work.

But if you have a folder which contains your documents and personal scripts and stuff you want to keep all your life, auto commit/push is the thing you want. This must be - of course - be prepared correctly too, like having an ignore file for "*.aux *.log *.out *.synctex.gz and the like.

You nearly always work in "work"
Backups will be created from "data"

Using links

Many files are somewhere in the system and you change them all the time. It is normally hard to ensure a backup of these. You have to use links.


You are using a work directory and have there a directory for your personal documents. Imagine something like this:

  • C:\work\andreas is checked out from "data".
  • "C:\Users\Andreas\.ssh\config" is a link which points to "C:\work\andreas\documents\always\ssh\config" ("always" is parallel to 2023, 2024...)

If you have it setup this way, you change the file "C:\Users\Andreas\.ssh\config" like normal, but backups of "data" will have the repository which is referenced by c:\work\andreas which contains the real file.

The same procedure is possible for other ssh files (keys etc..), ThunderBird Junk Training Data or whatever makes sense in your setup.

Create links with Linux

I did not test with Linux yet. So.. try if Mercurial recognizes changes in the link. Try soft- and hard links, if you have problems. When I know the correct answer for Linux I will put it here. Might take a while (days, weeks, months, years...).

Crates a soft link in .hg

cd .hg
ln -s ../.hg-configs-managed/hgrc-MY-CORPORATION-PC01 hgrc

Create links with Windows 10

Creates a soft link in .ssh

mklink c:\Users\Andreas\.ssh\test.txt C:\work\andreas\documents\always\keys\test.txt

Do not use hard links outside the repository. Mercurial does not recognize changes in files which are hard linked outside the repository. Your new problem might be that you need different rights to be able to use soft links, but it is worth it. No need to manually backup your important config/data files is worth it.