6 replaced http://raspberrypi.stackexchange.com/ with https://raspberrypi.stackexchange.com/
source | link

I have adapted @goldilocks answer on rsync for back-up on the pi. I backup to an ext4 partition on a HDD mounted on the Pi. If the HDD is not mounted, rsync would copy to the mount directory (until the SD Card is full). If the HDD is not mounted in rw mode copious error messages are produced. Neither of these is desirable, so I check that my partition is is mounted in rw mode before proceeding.

NOTE 2015-03-03 I modified my answer to accurately copy hardlinks. The original worked, but converted many hardlinks into files. In addition to wasting space, this compromises many uses which assume the hardlinks are in place. (My current image has 869 links, many in Raspbian itself.)

My script to do this follows. (My partition is PiData, mounted on /mnt/PiData

#!/bin/bash
# script to synchronise Pi files to backup
BACKUP_MOUNTED=$(mount | awk '/PiData/ {print $6}' | grep "rw")
if [ $BACKUP_MOUNTED ]; then
    echo $BACKUP_MOUNTED
    echo "Commencing Backup"
    rsync -avH --delete-during --delete-excluded --exclude-from=/usr/bin/rsync-exclude.txt / /mnt/PiData/PiBackup/
else
    echo "Backup drive not available or not writable"
fi

Restore (or update another Pi) with the following:-

sudo rsync -avH /mnt/PiData/PiBackup/ /

I have enhanced the rsync-exclude.txt to eliminate unnecessary files.

The first group are the directories documented by @goldilocks http://raspberrypi.stackexchange.com/users/5538/https://raspberrypi.stackexchange.com/users/5538/

The second group are the files and directories created by OS X when I access my Pi using AFP (Apple Filing Protocol). (These are normally invisible on OS X, but not on Raspbian. In any event, there is no need to backup.) Even if you never use AFP, these will do no harm.

The third group are files which do not need to be backed up (and certainly not copied to another Pi). Examples fake-hwclock.data, RPi-Monitor reports. You will probably have others.

/proc/*
/sys/*
/dev/*
/boot/*
/tmp/*
/run/*
/mnt/*

.Trashes
._.Trashes
.fseventsd
.Spotlight-V100
.DS_Store
.AppleDesktop
.AppleDB
Network Trash Folder
Temporary Items

.bash_history
/etc/fake-hwclock.data
/var/lib/rpimonitor/stat/

I have adapted @goldilocks answer on rsync for back-up on the pi. I backup to an ext4 partition on a HDD mounted on the Pi. If the HDD is not mounted, rsync would copy to the mount directory (until the SD Card is full). If the HDD is not mounted in rw mode copious error messages are produced. Neither of these is desirable, so I check that my partition is is mounted in rw mode before proceeding.

NOTE 2015-03-03 I modified my answer to accurately copy hardlinks. The original worked, but converted many hardlinks into files. In addition to wasting space, this compromises many uses which assume the hardlinks are in place. (My current image has 869 links, many in Raspbian itself.)

My script to do this follows. (My partition is PiData, mounted on /mnt/PiData

#!/bin/bash
# script to synchronise Pi files to backup
BACKUP_MOUNTED=$(mount | awk '/PiData/ {print $6}' | grep "rw")
if [ $BACKUP_MOUNTED ]; then
    echo $BACKUP_MOUNTED
    echo "Commencing Backup"
    rsync -avH --delete-during --delete-excluded --exclude-from=/usr/bin/rsync-exclude.txt / /mnt/PiData/PiBackup/
else
    echo "Backup drive not available or not writable"
fi

Restore (or update another Pi) with the following:-

sudo rsync -avH /mnt/PiData/PiBackup/ /

I have enhanced the rsync-exclude.txt to eliminate unnecessary files.

The first group are the directories documented by @goldilocks http://raspberrypi.stackexchange.com/users/5538/

The second group are the files and directories created by OS X when I access my Pi using AFP (Apple Filing Protocol). (These are normally invisible on OS X, but not on Raspbian. In any event, there is no need to backup.) Even if you never use AFP, these will do no harm.

The third group are files which do not need to be backed up (and certainly not copied to another Pi). Examples fake-hwclock.data, RPi-Monitor reports. You will probably have others.

/proc/*
/sys/*
/dev/*
/boot/*
/tmp/*
/run/*
/mnt/*

.Trashes
._.Trashes
.fseventsd
.Spotlight-V100
.DS_Store
.AppleDesktop
.AppleDB
Network Trash Folder
Temporary Items

.bash_history
/etc/fake-hwclock.data
/var/lib/rpimonitor/stat/

I have adapted @goldilocks answer on rsync for back-up on the pi. I backup to an ext4 partition on a HDD mounted on the Pi. If the HDD is not mounted, rsync would copy to the mount directory (until the SD Card is full). If the HDD is not mounted in rw mode copious error messages are produced. Neither of these is desirable, so I check that my partition is is mounted in rw mode before proceeding.

NOTE 2015-03-03 I modified my answer to accurately copy hardlinks. The original worked, but converted many hardlinks into files. In addition to wasting space, this compromises many uses which assume the hardlinks are in place. (My current image has 869 links, many in Raspbian itself.)

My script to do this follows. (My partition is PiData, mounted on /mnt/PiData

#!/bin/bash
# script to synchronise Pi files to backup
BACKUP_MOUNTED=$(mount | awk '/PiData/ {print $6}' | grep "rw")
if [ $BACKUP_MOUNTED ]; then
    echo $BACKUP_MOUNTED
    echo "Commencing Backup"
    rsync -avH --delete-during --delete-excluded --exclude-from=/usr/bin/rsync-exclude.txt / /mnt/PiData/PiBackup/
else
    echo "Backup drive not available or not writable"
fi

Restore (or update another Pi) with the following:-

sudo rsync -avH /mnt/PiData/PiBackup/ /

I have enhanced the rsync-exclude.txt to eliminate unnecessary files.

The first group are the directories documented by @goldilocks https://raspberrypi.stackexchange.com/users/5538/

The second group are the files and directories created by OS X when I access my Pi using AFP (Apple Filing Protocol). (These are normally invisible on OS X, but not on Raspbian. In any event, there is no need to backup.) Even if you never use AFP, these will do no harm.

The third group are files which do not need to be backed up (and certainly not copied to another Pi). Examples fake-hwclock.data, RPi-Monitor reports. You will probably have others.

/proc/*
/sys/*
/dev/*
/boot/*
/tmp/*
/run/*
/mnt/*

.Trashes
._.Trashes
.fseventsd
.Spotlight-V100
.DS_Store
.AppleDesktop
.AppleDB
Network Trash Folder
Temporary Items

.bash_history
/etc/fake-hwclock.data
/var/lib/rpimonitor/stat/
5 added 6 characters in body
source | link
#!/bin/bash
# script to synchronise Pi files to backup
BACKUP_MOUNTED=$(mount | awk '/PiData/ {print $6}' | grep "rw")
if [ $BACKUP_MOUNTED ]; then
    echo $BACKUP_MOUNTED
    echo "Commencing Backup"
    rsync -avH --delete-during --delete-excluded --exclude-from=/usr/bin/rsync-exclude.txt / /mnt/PiData/PiBackup/
else
    echo "Backup drive not available or not writable"
fi
#!/bin/bash
# script to synchronise Pi files to backup
BACKUP_MOUNTED=$(mount | awk '/PiData/ {print $6}' | grep "rw")
if [ $BACKUP_MOUNTED ]; then
    echo $BACKUP_MOUNTED
    echo "Commencing Backup"
    rsync -avH --delete-during --delete-excluded --exclude-from=/usr/bin/rsync-exclude.txt / /mnt/PiData/PiBackup/
else
    echo "Backup drive not available or not writable"
fi
sudo rsync -avH /mnt/PiData/PiBackup/ /
sudo rsync -avH /mnt/PiData/PiBackup/ /
/proc/*
/sys/*
/dev/*
/boot/*
/tmp/*
/run/*
/mnt/*

.Trashes
._.Trashes
.fseventsd
.Spotlight-V100
.DS_Store
.AppleDesktop
.AppleDB
Network Trash Folder
Temporary Items

.bash_history
/etc/fake-hwclock.data
/var/lib/rpimonitor/stat/
/proc/*
/sys/*
/dev/*
/boot/*
/tmp/*
/run/*
/mnt/*

.Trashes
._.Trashes
.fseventsd
.Spotlight-V100
.DS_Store
.AppleDesktop
.AppleDB
Network Trash Folder
Temporary Items

.bash_history
/etc/fake-hwclock.data
/var/lib/rpimonitor/stat/
#!/bin/bash
# script to synchronise Pi files to backup
BACKUP_MOUNTED=$(mount | awk '/PiData/ {print $6}' | grep "rw")
if [ $BACKUP_MOUNTED ]; then
    echo $BACKUP_MOUNTED
    echo "Commencing Backup"
    rsync -avH --delete-during --delete-excluded --exclude-from=/usr/bin/rsync-exclude.txt / /mnt/PiData/PiBackup/
else
    echo "Backup drive not available or not writable"
fi
sudo rsync -avH /mnt/PiData/PiBackup/ /
/proc/*
/sys/*
/dev/*
/boot/*
/tmp/*
/run/*
/mnt/*

.Trashes
._.Trashes
.fseventsd
.Spotlight-V100
.DS_Store
.AppleDesktop
.AppleDB
Network Trash Folder
Temporary Items

.bash_history
/etc/fake-hwclock.data
/var/lib/rpimonitor/stat/
#!/bin/bash
# script to synchronise Pi files to backup
BACKUP_MOUNTED=$(mount | awk '/PiData/ {print $6}' | grep "rw")
if [ $BACKUP_MOUNTED ]; then
    echo $BACKUP_MOUNTED
    echo "Commencing Backup"
    rsync -avH --delete-during --delete-excluded --exclude-from=/usr/bin/rsync-exclude.txt / /mnt/PiData/PiBackup/
else
    echo "Backup drive not available or not writable"
fi
sudo rsync -avH /mnt/PiData/PiBackup/ /
/proc/*
/sys/*
/dev/*
/boot/*
/tmp/*
/run/*
/mnt/*

.Trashes
._.Trashes
.fseventsd
.Spotlight-V100
.DS_Store
.AppleDesktop
.AppleDB
Network Trash Folder
Temporary Items

.bash_history
/etc/fake-hwclock.data
/var/lib/rpimonitor/stat/
4 added 29 characters in body
source | link

I have adapted @goldilocks answer on rsync for back-up on the pi. I backup to an ext4 partition on a HDD mounted on the Pi. If the HDD is not mounted, rsync would copy to the mount directory (until the SD Card is full). If the HDD is not mounted in rw mode copious error messages are produced. Neither of these is desirable, so I check that my partition is is mounted in rw mode before proceeding.

NOTE 2015-03-03 I modified my answer to accurately copy hardlinks. The original worked, but converted many hardlinks into files. In addition to wasting space, this compromises many uses which assume the hardlinks are in place. (My current image has 869 links, many in Raspbian itself.)

My script to do this follows. (My partition is PiData, mounted on /mnt/PiData 

#!/bin/bash
# script to synchronise Pi files to backup
BACKUP_MOUNTED=$(mount | awk '/PiData/ {print $6}' | grep "rw")
if [ $BACKUP_MOUNTED ]; then
    echo $BACKUP_MOUNTED
    echo "Commencing Backup"
    rsync -avH --delete-during --delete-excluded --exclude-from=/usr/bin/rsync-exclude.txt / /mnt/PiData/PiBackup/
else
    echo "Backup drive not available or not writable"
fi

Restore (or update another Pi) with the following:-

sudo rsync -avH /mnt/PiData/PiBackup/ /

I have enhanced the rsync-exclude.txt to eliminate unnecessary files.

The first group are the directories documented by @goldilocks http://raspberrypi.stackexchange.com/users/5538/

The second group are the files and directories created by OS X when I access my Pi using AFP (Apple Filing Protocol). (These are normally invisible on OS X, but not on Raspbian. In any event, there is no need to backup.) Even if you never use AFP, these will do no harm.

The third group are files which do not need to be backed up (and certainly not copied to another Pi). Examples fake-hwclock.data, RPi-Monitor reports. You will probably have others.

/proc/*
/sys/*
/dev/*
/boot/*
/tmp/*
/run/*
/mnt/*

.Trashes
._.Trashes
.fseventsd
.Spotlight-V100
.DS_Store
.AppleDesktop
.AppleDB
Network Trash Folder
Temporary Items

.bash_history
/etc/fake-hwclock.data
/var/lib/rpimonitor/stat/

I have adapted @goldilocks answer on rsync for back-up on the pi. I backup to an ext4 partition on a HDD mounted on the Pi. If the HDD is not mounted, rsync would copy to the mount directory (until the SD Card is full). If the HDD is not mounted in rw mode copious error messages are produced. Neither of these is desirable, so I check that my partition is is mounted in rw mode before proceeding.

NOTE 2015-03-03 I modified my answer to accurately copy hardlinks. The original worked, but converted many hardlinks into files. In addition to wasting space, this compromises many uses which assume the hardlinks are in place. (My current image has 869 links, many in Raspbian itself.)

My script to do this follows. (My partition is PiData, mounted on /mnt/PiData

#!/bin/bash
# script to synchronise Pi files to backup
BACKUP_MOUNTED=$(mount | awk '/PiData/ {print $6}' | grep "rw")
if [ $BACKUP_MOUNTED ]; then
    echo $BACKUP_MOUNTED
    echo "Commencing Backup"
    rsync -avH --delete-during --delete-excluded --exclude-from=/usr/bin/rsync-exclude.txt / /mnt/PiData/PiBackup/
else
    echo "Backup drive not available or not writable"
fi

Restore (or update another Pi) with the following:-

sudo rsync -avH /mnt/PiData/PiBackup/ /

I have enhanced the rsync-exclude.txt to eliminate unnecessary files.

The first group are the directories documented by @goldilocks http://raspberrypi.stackexchange.com/users/5538/

The second group are the files and directories created by OS X when I access my Pi using AFP (Apple Filing Protocol). (These are normally invisible on OS X, but not on Raspbian. In any event, there is no need to backup.) Even if you never use AFP, these will do no harm.

The third group are files which do not need to be backed up (and certainly not copied to another Pi). Examples fake-hwclock.data, RPi-Monitor reports. You will probably have others.

/proc/*
/sys/*
/dev/*
/boot/*
/tmp/*
/run/*
/mnt/*

.Trashes
._.Trashes
.fseventsd
.Spotlight-V100
.DS_Store
.AppleDesktop
.AppleDB
Network Trash Folder
Temporary Items

.bash_history
/etc/fake-hwclock.data
/var/lib/rpimonitor/stat/

I have adapted @goldilocks answer on rsync for back-up on the pi. I backup to an ext4 partition on a HDD mounted on the Pi. If the HDD is not mounted, rsync would copy to the mount directory (until the SD Card is full). If the HDD is not mounted in rw mode copious error messages are produced. Neither of these is desirable, so I check that my partition is is mounted in rw mode before proceeding.

NOTE 2015-03-03 I modified my answer to accurately copy hardlinks. The original worked, but converted many hardlinks into files. In addition to wasting space, this compromises many uses which assume the hardlinks are in place. (My current image has 869 links, many in Raspbian itself.)

My script to do this follows. (My partition is PiData, mounted on /mnt/PiData 

#!/bin/bash
# script to synchronise Pi files to backup
BACKUP_MOUNTED=$(mount | awk '/PiData/ {print $6}' | grep "rw")
if [ $BACKUP_MOUNTED ]; then
    echo $BACKUP_MOUNTED
    echo "Commencing Backup"
    rsync -avH --delete-during --delete-excluded --exclude-from=/usr/bin/rsync-exclude.txt / /mnt/PiData/PiBackup/
else
    echo "Backup drive not available or not writable"
fi

Restore (or update another Pi) with the following:-

sudo rsync -avH /mnt/PiData/PiBackup/ /

I have enhanced the rsync-exclude.txt to eliminate unnecessary files.

The first group are the directories documented by @goldilocks http://raspberrypi.stackexchange.com/users/5538/

The second group are the files and directories created by OS X when I access my Pi using AFP (Apple Filing Protocol). (These are normally invisible on OS X, but not on Raspbian. In any event, there is no need to backup.) Even if you never use AFP, these will do no harm.

The third group are files which do not need to be backed up (and certainly not copied to another Pi). Examples fake-hwclock.data, RPi-Monitor reports. You will probably have others.

/proc/*
/sys/*
/dev/*
/boot/*
/tmp/*
/run/*
/mnt/*

.Trashes
._.Trashes
.fseventsd
.Spotlight-V100
.DS_Store
.AppleDesktop
.AppleDB
Network Trash Folder
Temporary Items

.bash_history
/etc/fake-hwclock.data
/var/lib/rpimonitor/stat/
3 error in rsync option ('H')
source | link
2 Modified for hardlinks
source | link
1
source | link