How to make a back up, encript it using gpg and copy it to a remote site using ssh
Below is a script that I wrote to back up a bunch of files, tar them and then compress them. Why use two different programs, tar and zip, because it is the UNIX way. Use one specialty program to do one thing, and one thing very well. If you put too many features into your UNIX programs then they just grow too monstrous and unmanageable like Windows (just a example).
#!/bin/bash#Written By: BAB
#The purpose of this script is to back up all directories listed, compress the directories, encript the directories, and send them to a remote site.
#compressioin /bin/bzip2
#archiving /bin/tar
#encription /usr/bin/gpg
ZIP=/bin/bzip2
TAR=/bin/tar
ENCRYPT=/usr/bin/gpg
RM=/usr/bin/rm
DATE=`/usr/bin/date +%m/%d/%Y`BACKUPDIRS=/home/one /home/two
BACKUPNAME=server-backup$DATE
REMOTESERVER=server.comREMOTEUSERNAME=username
GPGNAME=my name
echo “starting backup”
echo ” AKA tar”
$TAR -cf $BACKUPNAME.tar $BACKUPDIRS
echo “Starting zip”
$ZIP -z $BACKUPNAME.tarecho “starting encryption”
$ENCRYPT –encrypt –recipient ‘$GPGNAME’ BACKUPNAME.tarecho “sending to remote site one”
scp FILE $REMOTEUSERNAME@REMOTESERVER:~echo “doing cleanup”
$RM $BACKUPNAME.tar.gpg
echo “cleanup done”echo “Backup Complete!”
#echo “Decripting the file”
#gpg –output foo.txt –decrypt foo.txt.gpg# echo “Usage: $0 {-encript -decript}” >&2
# exit 1
# ;;
#esac#exit 0