Synchronize Files to Disk

How to synchronize files on an external disk connected to your HTPC ?
You could use “rsync” to make your backup on the storage.

1. Create the backup directory

sudo mkdir /backup

2. Find the UUID of the disk

sudo fdisk -l
sudo blkid

3. Configure /etc/fstab

# Backup filesystem
UUID=551e7f52-4b25-4190-a5b0-944eaf7caedd /backup    ext4    defaults,nobootwait    0     2

4. Restart the system

sudo reboot

5. Synchronize your files to disk

#!/bin/sh

/bin/mount | /bin/grep /backup >/dev/null

if [ "$?" -eq "0" ]; then
    /usr/bin/rsync -avh --delete /data/ /backup/ && sleep 5 && /sbin/shutdown -h now;
    exit 0;
else
    exit 0;
fi

6. Schedule your backup with crontab

00 01 * * * /root/backup.sh