A Simple BASH Backup Script
A very simple command script to mirror the all the Linkstation 2 share data to a USB drive.
It simply works out what is on the destination, but is not in the source, and deletes it from the destination. Then it uses the “copy” command with the “-
The Backup Script “ls-
#!/bin/bash
#Name: ls-
#Usage: ./ls-
#Example crontab entry to run the script at 7am every Sunday:
# 00 7 * * 0 /mnt/usbdisk1/ls-
#A simple script to backup the LinkStation HDD Shares to a USB HDD.
#It is a Mirror backup. New/modified files copied & deleted files removed.
#Source & Destination directories.
srcdir="/mnt/hda"
dstdir="/mnt/usbdisk1/HDA-
if [ -
echo "****************************"
date
echo "****************************"
echo
echo "Starting the LinkStation All Shares backup..."
echo " SRC:/$srcdir -
echo
echo "Checking Dst files..."
cd "$dstdir"
find . -
do
if [ ! -
echo "No longer in Source: $file"
rm -
fi
done
echo
echo "Copying Src files..."
cp -
echo
echo "Backup finished."
echo
echo "****************************"
date
echo "****************************"
else
echo
echo "Path(s) not found... Check that the Src & Dst directories exist!"
fi
Automation Via “crontab”
To perform a backup at 7am every Sunday, add this to /etc/crontab
export EDITOR=vi
crontab -
00 7 * * 0 /mnt/usbdisk1/ls-