Back then when I used Macs, I was highly appreciative of a tool that was once introduced to safely back up your data: Time Machine. This tool was (and is? Does Apple still ship this with Macs?) basically a super funky implementation of a collection of rsync commands, wrapped into a fancy UI. Eventually in over time you'd create something like a timeline of files and folders that had changed. You could go back to earlier versions of any files and folders, should you need it.

Since my rig is now completely running off of QEMU virtualized images, deleting those images would also mean deleting all my data. Which is, obviously, not desired. So I did some research. rsync is a native tool to the Linux/Unix world, so it should be possible to achieve the same backup mechanism as Time Machine does.

I attached my old 2TB HD to my server, slammed an ext4 filesystem on it, and, of course, called the mount point TimeMachine. Through sshfs I can mount this network backup drive to my main VM. This happens automatically when I log in.

I found this super useful gem: Rsync time backup. It basically mimics exactly what Time Machine on Macs does.

Run a base backup with this script first. Then, it will create backups of files and folders that have changed, creating hard links for non-changed files along the way. The "latest" symlink in your destination folder will point to the most current version of your complete data set. This minimizes the amount of data needed to be backed up, you always have the current version of your data in the symlink, plus, you can always go back to an earlier state of any of your files at any time, at will.

Or, to summarize: It's Time Machine.

Here's a revised script of what I use now:

The "TIMEDILATION" variable points to the copy of the script provided in the above GitHub, I just renamed it.

# Location of Time Machine

# Location of actual Time Machine script

# Root of home folder inside which we find the folders below

# List of folders to back up
declare -a incl=(

# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------

yad --notification --image=/home/marcus/.timemachine/tm.png &

# Check if folders exist in destination
for i in "${incl[@]}"
if [ ! -d "$TIMEMACHINE/$i" ]; then
touch $TIMEMACHINE/$i/backup.marker

# We can now walk through the inclusion list
# and create Time Machine backups for every folder
# we have specified.

for i in "${incl[@]}"

killall yad

And to make it fully operational like Time Machine's "Set It Then Forget It" attribute, I created a cronjob via crontab -e like so:

0 */1 * * * if grep -qs /home/marcus/Network/TimeMachine /proc/mounts; then /home/marcus/Private/Scripts/TimeMachine/; fi

And we can see, it's beginning to build a timeline:


Back to content