2014-02-14 Backup

This got started on 2006-08-03 Backup using rsync. We’re using several external USB harddisks to keep backups. The most important part is that we have two external disks and we keep at least one of them at Claudia’s office. Just making sure that a simple fire in our flat cannot destroy all our data. I do backups using rsync. Note my Restore page.

2006-08-03 Backup using rsync

rsync

Restore

Look at how the external drives are setup. The Extern disk is always connected and it’s where both I and Claudia keep files such as the iTunes library. That’s why it has the “noowners” flag set. The Backup disk, on the other hand, needs to preserve ownership.

alex@Megabombus:~$ mount
/dev/disk0s2 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)
/dev/disk2s3 on /Volumes/Backup (hfs, local, nodev, nosuid, journaled)
/dev/disk1s2 on /Volumes/Extern (hfs, local, nodev, nosuid, journaled, noowners)

I run this from my main machine, Megabombus.

#!/bin/bash

if [ ! -d /Volumes/Backup ]; then
    echo you need to mount the backup drive, first
    exit
fi

if [ -z "$1" -o "$1" == "Megabombus" ]; then
    echo Megabombus
    sudo rsync --archive --delete --delete-excluded \
	--itemize-changes \
	--exclude=.Spotlight-V100 --exclude=.DS_Store \
	--exclude="/Users/*/Library/Caches" \
	--exclude="/Users/*/.Trash" --exclude="/.Trashes" \
	--exclude="/Volumes" --exclude=".fseventsd" \
	--exclude="/Users/*/Library/Application Support/Wuala/Data/Temp" \
	/ /Volumes/Backup/Machines/Megabombus
else
    echo skipping Megabombus
fi

if [ -d /Volumes/Extern -a \( -z "$1" -o "$1" == "Extern" \) ]; then
    echo Extern
    sudo rsync \
	--itemize-changes \
	--partial --archive --delete --delete-excluded --verbose \
	--exclude=.Spotlight-V100 --exclude=.DS_Store \
	--exclude=/Extern/.Trashes --exclude=/Extern/.fseventsd \
	/Volumes/Extern /Volumes/Backup
else
    echo skipping Extern
fi

if [ -z "$1" -o "$1" == "Psithyrus" -o "$1" == "net" ]; then
    echo Psithyrus
    rsync --archive --verbose --compress --delete --delete-excluded \
	--itemize-changes \
	--exclude '/logs' \
	--exclude '/planet/rpg' \
	--exclude 'temp/' \
	--exclude 'pids/' \
	--exclude 'visitors.log' \
	--exclude 'referer/' \
	--exclude '.git/' \
	--iconv=UTF8-MAC,UTF-8 \
	alex@psithyrus.epfarms.org:/home/alex/ \
	/Volumes/Backup/Machines/psithyrus/
else
    echo skipping Psithyrus
fi

if [ -z "$1" -o "$1" == "Emacs Wiki" -o "$1" == "net" ]; then
    echo Emacs Wiki
    rsync --archive --verbose --compress --delete --delete-excluded \
	--itemize-changes \
	--exclude '/org.emacswiki/logs' \
	--exclude '/org.emacswiki/htdocs/*/visitors.log' \
	--exclude '/org.emacswiki/htdocs/*/pids/' \
	--exclude '/org.emacswiki/htdocs/*/temp/' \
	--exclude '/org.emacswiki/htdocs/*/referer' \
	--exclude '/org.emacswiki/htdocs/emacs/git' \
	--iconv=UTF8-MAC,UTF-8 \
	aschroeder@web.moinmo.in:/org/org.emacswiki \
	/Volumes/Backup/Machines/moinmo.in
else
    echo skipping Emacs Wiki
fi

if [ -z "$1" -o "$1" == "Raspberry Pi" -o "$1" == "net" ]; then
    echo Raspberry Pi
    if ping -q -c1 raspberrypi.local > /dev/null; then
      for ME in pi alex; do
        echo ... $ME
	mkdir -p /Volumes/Backup/Machines/raspberrypi.local/home/$ME
	rsync --archive --verbose --compress --delete --delete-excluded \
	    --iconv=UTF8-MAC,UTF-8 \
	    $ME@raspberrypi.local: \
	    /Volumes/Backup/Machines/raspberrypi.local/home/$ME
      done
    else
	notify Raspberry Pi cannot be reached
    fi
else
    echo skipping Raspberry Pi
fi

if [ -z "$1" -o "$1" == "Subterraneobombus" -o "$1" == "net" ]; then
    echo Subterraneobombus
    if ping -q -c1 subterraneobombus.local > /dev/null; then
	rsync --archive --verbose --compress --delete --delete-excluded \
	    --exclude '/tmp' \
	    --exclude '/dev' --exclude '/proc' --exclude '/sys' \
	    --exclude '/home/alex/.local/share/Trash' \
	    --exclude '/home/alex/.mozilla/firefox/*/Cache' \
	    --exclude '/home/alex/Videos' \
	    --iconv=UTF8-MAC,UTF-8 \
	    alex@subterraneobombus.local:/ \
	    /Volumes/Backup/Machines/subterraneobombus.local/
    else
	notify Subterraneobombus cannot be reached
    fi
else
    echo skipping Subterraneobombus
fi

notify Backup finished.

​#Backup

Comments

(Please contact me if you want to remove your comment.)

These days I have a script like the following:

#!/bin/bash

# sibirocobombus.root is defined in ~/.ssh/config

# Using sudo rsync --archive to preserve ownership.
# Using --fake-super to avoid changes to groups and owners

echo Backing up Sibirocobombus
echo home directory
rsync --archive --fake-super --verbose --compress --delete --delete-excluded \
      --itemize-changes \
      --exclude '/home/alex/alexschroeder.ch/share' \
      --exclude '/home/alex/planet/osr/' \
      --exclude '/home/alex/planet/indie/' \
      --exclude '/home/alex/planet/other/' \
      --exclude '/home/alex/planet/alex/' \
      --exclude '.cpan/build' \
      --exclude '.cpan/sources' \
      --exclude '.cpanm' \
      --exclude '.cache' \
      --exclude '.Trash' \
      --exclude '.local/share/Trash' \
      --exclude 'temp/' \
      --exclude 'visitors.log' \
      --exclude 'referer/' \
      --exclude '.git/' \
      sibirocobombus.root:/home \
      /home/alex/Documents/Sibirocobombus

# https://www.debian.org/releases/buster/amd64/release-notes/ch-upgrading.en.html#data-backup
echo etc directory
rsync --archive --fake-super --verbose --compress --delete --delete-excluded \
      --itemize-changes \
      sibirocobombus.root:/etc \
      sibirocobombus.root:/var/lib/dpkg \
      sibirocobombus.root:/var/lib/apt/extended_states \
      sibirocobombus.root:/var/lib/radicale \
      sibirocobombus.root:/usr/lib/cgit/filters \
      sibirocobombus.root:/home/gotosocial \
      sibirocobombus.root:/home/git \
      /home/alex/Documents/Sibirocobombus

– Alex 2023-05-25 17:46 UTC