Datasheet
bash backup | less
chmod +x backup
#!/bin/bash
./backup
#!/bin/bash
# Simple program to make a backup of files on the Raspberry Pi
# Set the location of my files and the backup location
mydirectory="/home/pi"
safeplace="/backup"
echo "Starting backup of files from $mydirectory to $safeplace"
# Check if the backup directory exists
if [ ! -d $safeplace ]
then
# Does not exist, need to make a new directory
echo "Making new directory $safeplace"
sudo mkdir $safeplace
# Change owner of this directory to the user pi
sudo chown pi $safeplace
fi
# Copy all the files in my directory
# recursive means keep drilling down into directories to find files
# update means only copy files that have been changed since the last backup
# verbose means I want to be told what is happening
cp --recursive --update --verbose $mydirectory $safeplace
echo "Backup is finished"