Improving local backup script

This commit is contained in:
Bob Mottram 2015-09-24 21:06:10 +01:00
parent 24067c7e13
commit cb60115210
1 changed files with 104 additions and 90 deletions

View File

@ -2416,64 +2416,74 @@ function get_mariadb_owncloud_admin_password {
}
function backup_directory_to_usb {
echo "if [ ! -d ${1} ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " echo \"WARNING: directory does not exist: ${1}\"" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'else' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'function backup_directory_to_usb {' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " MY_NAME=\"$MY_NAME\"" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " USB_MOUNT=$USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! -d ${1} ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "WARNING: directory does not exist: ${1}"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' else' >> /usr/bin/$BACKUP_SCRIPT_NAME
if [[ $BACKUP_TYPE == 'obnam' ]]; then
BACKUP_KEY_EXISTS=$(gpg --list-keys "$MY_NAME (backup key)")
if [ ! "$?" = "0" ]; then
echo "Backup key could not be found"
exit 43382
fi
MY_BACKUP_KEY_ID=$(gpg --list-keys "$MY_NAME (backup key)" | grep 'pub ' | awk -F ' ' '{print $2}' | awk -F '/' '{print $2}')
echo " obnam backup -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' BACKUP_KEY_EXISTS=$(gpg --list-keys "$MY_NAME (backup key)")' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backup key could not be found"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' exit 43382' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' MY_BACKUP_KEY_ID=$(gpg --list-keys "$MY_NAME (backup key)" | grep "pub " | awk -F " " "{print $2}" | awk -F "/" "{print $2}")' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' obnam backup -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}' >> /usr/bin/$BACKUP_SCRIPT_NAME
else
# For rsyncrypto usage see http://archive09.linux.com/feature/125322
echo " rsyncrypto -v -r ${1} $USB_MOUNT/backup/${2} $USB_MOUNT/backup/${2}.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " BACKUP_CERTIFICATE=$BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' rsyncrypto -v -r ${1} $USB_MOUNT/backup/${2} $USB_MOUNT/backup/${2}.keys $BACKUP_CERTIFICATE' >> /usr/bin/$BACKUP_SCRIPT_NAME
fi
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
echo " shred -zu ${1}/*" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf ${1}" >> /usr/bin/$BACKUP_SCRIPT_NAME
fi
echo ' exit 853' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' umount $USB_MOUNT' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' rm -rf $USB_MOUNT' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' shred -zu ${1}/*"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' rm -rf ${1}' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' exit 853' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' shred -zu ${1}/*' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' rm -rf ${1}' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
echo " shred -zu ${1}/*" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf ${1}" >> /usr/bin/$BACKUP_SCRIPT_NAME
fi
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '}' >> /usr/bin/$BACKUP_SCRIPT_NAME
}
function backup_database {
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "if [ ! -d $USB_MOUNT/backup/${1} ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/${1}" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "if [ ! -d $USB_MOUNT/backup/${1}data ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/${1}data" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "if [ ! -d /root/temp${1}data ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p /root/temp${1}data" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "echo \"Obtaining ${1} database backup\"" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo -n 'mysqldump --password=$DATABASE_PASSWORD ' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "${1} > /root/temp${1}data/${1}.sql" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "if [ ! -s /root/temp${1}data/${1}.sql ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " echo \"${1} database could not be saved\"" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! $DATABASE_PASSWORD ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " echo 'No MariaDB password was given'" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " fi" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " shred -zu /root/temp${1}data/*" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf /root/temp${1}data" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' exit 296' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "fi" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'function backup_database {' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " USB_MOUNT=$USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " DATABASE_PASSWORD='$DATABASE_PASSWORD'" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! -d $USB_MOUNT/backup/${1} ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' mkdir -p $USB_MOUNT/backup/${1}' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! -d $USB_MOUNT/backup/${1}data ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' mkdir -p $USB_MOUNT/backup/${1}data' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! -d /root/temp${1}data ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' mkdir -p /root/temp${1}data' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Obtaining ${1} database backup"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo -n ' mysqldump --password=$DATABASE_PASSWORD ' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '${1} > /root/temp${1}data/${1}.sql' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! -s /root/temp${1}data/${1}.sql ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "${1} database could not be saved"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! $DATABASE_PASSWORD ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "No MariaDB password was given"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' shred -zu /root/temp${1}data/*' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' rm -rf /root/temp${1}data' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' umount $USB_MOUNT' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' rm -rf $USB_MOUNT' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' exit 296' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '}' >> /usr/bin/$BACKUP_SCRIPT_NAME
}
function create_backup_script {
@ -2535,6 +2545,10 @@ function create_backup_script {
echo ' exit 27' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_database
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
if [[ $BACKUP_TYPE != 'obnam' ]]; then
echo "if [ ! -f $BACKUP_CERTIFICATE ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2556,18 +2570,18 @@ function create_backup_script {
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
if grep -Fxq "install_gnu_social" $COMPLETION_FILE; then
BACKUP_INCLUDES_DATABASES="yes"
backup_database gnusocial
backup_directory_to_usb '/root/tempgnusocialdata' 'gnusocialdata'
echo 'backup_database gnusocial' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'backup_directory_to_usb /root/tempgnusocialdata gnusocialdata' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'echo "Backing up GNU social installation"' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb /var/www/$MICROBLOG_DOMAIN_NAME/htdocs gnusocial
echo "backup_directory_to_usb /var/www/$MICROBLOG_DOMAIN_NAME/htdocs gnusocial" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
fi
if grep -Fxq "install_hubzilla" $COMPLETION_FILE; then
BACKUP_INCLUDES_DATABASES="yes"
backup_database hubzilla
backup_directory_to_usb '/root/temphubzilladata' 'hubzilladata'
echo 'backup_database hubzilla' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'backup_directory_to_usb /root/temphubzilladata hubzilladata' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'echo "Backing up Hubzilla installation"' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb /var/www/$HUBZILLA_DOMAIN_NAME/htdocs hubzilla
echo "backup_directory_to_usb /var/www/$HUBZILLA_DOMAIN_NAME/htdocs hubzilla" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
fi
if grep -Fxq "install_owncloud" $COMPLETION_FILE; then
@ -2575,11 +2589,11 @@ function create_backup_script {
echo "if [ ! -d $USB_MOUNT/backup/owncloud2 ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/owncloud2" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_database owncloud
backup_directory_to_usb '/root/tempownclouddata' 'ownclouddata'
echo 'backup_database owncloud' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'backup_directory_to_usb /root/tempownclouddata ownclouddata' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'echo "Obtaining Owncloud data backup"' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb '/var/lib/owncloud' 'owncloud'
backup_directory_to_usb '/etc/owncloud' 'owncloud2'
echo 'backup_directory_to_usb /var/lib/owncloud owncloud' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'backup_directory_to_usb /etc/owncloud owncloud2' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
fi
if grep -Fxq "install_gogs" $COMPLETION_FILE; then
@ -2590,15 +2604,15 @@ function create_backup_script {
echo "if [ ! -d $USB_MOUNT/backup/gogsssh ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/gogsssh" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_database gogs
backup_directory_to_usb '/root/tempgogsdata' 'gogsdata'
echo 'backup_database gogs' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'backup_directory_to_usb /root/tempgogsdata gogsdata' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'echo "Obtaining Gogs settings backup"' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb '/home/git/go/src/github.com/gogits/gogs/custom' 'gogs'
echo 'backup_directory_to_usb /home/git/go/src/github.com/gogits/gogs/custom gogs' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'echo "Obtaining Gogs repos backup"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "mv /home/git/gogs-repositories/*.git /home/git/gogs-repositories/$MY_USERNAME" >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb '/home/git/gogs-repositories' 'gogsrepos'
echo 'mv /home/git/gogs-repositories/*.git /home/git/gogs-repositories/$MY_USERNAME' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'backup_directory_to_usb /home/git/gogs-repositories gogsrepos' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'echo "Obtaining Gogs authorized_keys backup"' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb '/home/git/.ssh' 'gogsssh'
echo 'backup_directory_to_usb /home/git/.ssh gogsssh' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
fi
if grep -Fxq "install_wiki" $COMPLETION_FILE; then
@ -2609,8 +2623,8 @@ function create_backup_script {
echo " mkdir -p $USB_MOUNT/backup/wiki2" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'echo "Obtaining wiki data backup"' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb '/var/lib/dokuwiki' 'wiki'
backup_directory_to_usb '/etc/dokuwiki' 'wiki2'
echo 'backup_directory_to_usb /var/lib/dokuwiki wiki' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'backup_directory_to_usb /etc/dokuwiki wiki2' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
fi
if grep -Fxq "install_blog" $COMPLETION_FILE; then
@ -2618,7 +2632,7 @@ function create_backup_script {
echo " mkdir -p $USB_MOUNT/backup/blog" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'echo "Obtaining blog backup"' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb "/var/www/$FULLBLOG_DOMAIN_NAME/htdocs" 'blog'
echo "backup_directory_to_usb /var/www/$FULLBLOG_DOMAIN_NAME/htdocs blog" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
fi
if grep -Fxq "mesh_cjdns" $COMPLETION_FILE; then
@ -2626,7 +2640,7 @@ function create_backup_script {
echo " mkdir -p $USB_MOUNT/backup/cjdns" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'echo "Obtaining cjdns backup"' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb '/etc/cjdns' 'cjdns'
echo 'backup_directory_to_usb /etc/cjdns cjdns' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
fi
@ -2637,7 +2651,7 @@ function create_backup_script {
echo " if [ ! -d $USB_MOUNT/backup/ssl ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/ssl" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb /etc/ssl ssl
echo ' backup_directory_to_usb /etc/ssl ssl' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2647,7 +2661,7 @@ function create_backup_script {
echo " if [ ! -d $USB_MOUNT/backup/projects ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/projects" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb '/home/$MY_USERNAME/projects' 'projects'
echo ' backup_directory_to_usb /home/$MY_USERNAME/projects projects' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2657,7 +2671,7 @@ function create_backup_script {
echo " if [ ! -d $USB_MOUNT/backup/personal ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/personal" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb '/home/$MY_USERNAME/personal' 'personal'
echo ' backup_directory_to_usb /home/$MY_USERNAME/personal personal' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2667,7 +2681,7 @@ function create_backup_script {
echo " if [ ! -d $USB_MOUNT/backup/mailinglist ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/mailinglist" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb "$PUBLIC_MAILING_LIST_DIRECTORY" 'mailinglist'
echo " backup_directory_to_usb $PUBLIC_MAILING_LIST_DIRECTORY mailinglist" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2677,7 +2691,7 @@ function create_backup_script {
echo " if [ ! -d $USB_MOUNT/backup/xmpp ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/xmpp" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb "$XMPP_DIRECTORY" "xmpp"
echo " backup_directory_to_usb $XMPP_DIRECTORY xmpp" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2687,7 +2701,7 @@ function create_backup_script {
echo " if [ ! -d $USB_MOUNT/backup/gnupg ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/gnupg" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb '/home/$MY_USERNAME/.gnupg' 'gnupg'
echo ' backup_directory_to_usb /home/$MY_USERNAME/.gnupg gnupg' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2697,7 +2711,7 @@ function create_backup_script {
echo " if [ ! -d $USB_MOUNT/backup/ssh ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/ssh" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb '/home/$MY_USERNAME/.ssh' 'ssh'
echo ' backup_directory_to_usb /home/$MY_USERNAME/.ssh ssh' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2707,7 +2721,7 @@ function create_backup_script {
echo " if [ ! -d $USB_MOUNT/backup/web ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/web" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb '/etc/nginx/sites-available' 'web'
echo ' backup_directory_to_usb /etc/nginx/sites-available web' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2721,7 +2735,7 @@ function create_backup_script {
echo ' mkdir -p /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' cp -f /home/$MY_USERNAME/README /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb '/home/$MY_USERNAME/tempbackup' 'readme'
echo ' backup_directory_to_usb /home/$MY_USERNAME/tempbackup readme' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2731,7 +2745,7 @@ function create_backup_script {
echo " if [ ! -d $USB_MOUNT/backup/ipfs ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/ipfs" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb '/home/$MY_USERNAME/.ipfs' 'ipfs'
echo ' backup_directory_to_usb /home/$MY_USERNAME/.ipfs ipfs' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2748,7 +2762,7 @@ function create_backup_script {
echo " if [ ! -d $USB_MOUNT/backup/mutt ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/mutt" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb '/home/$MY_USERNAME/tempbackup' 'mutt'
echo ' backup_directory_to_usb /home/$MY_USERNAME/tempbackup mutt' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2762,7 +2776,7 @@ function create_backup_script {
echo " if [ ! -d $USB_MOUNT/backup/procmail ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/procmail" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb '/home/$MY_USERNAME/tempbackup' 'procmail'
echo ' backup_directory_to_usb /home/$MY_USERNAME/tempbackup procmail' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2772,7 +2786,7 @@ function create_backup_script {
echo " if [ ! -d $USB_MOUNT/backup/spamassassin ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/spamassassin" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb '/home/$MY_USERNAME/.spamassassin' 'spamassassin'
echo ' backup_directory_to_usb /home/$MY_USERNAME/.spamassassin spamassassin' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2787,7 +2801,7 @@ function create_backup_script {
echo " if [ ! -d $USB_MOUNT/backup/mail ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/mail" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb '/root/tempbackupemail' 'mail'
echo ' backup_directory_to_usb /root/tempbackupemail mail' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2797,7 +2811,7 @@ function create_backup_script {
echo " if [ ! -d $USB_MOUNT/backup/dlna ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/dlna" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb '/var/cache/minidlna' 'dlna'
echo ' backup_directory_to_usb /var/cache/minidlna dlna' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2814,7 +2828,7 @@ function create_backup_script {
echo " if [ ! -d $USB_MOUNT/backup/voip ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/voip" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb '/home/$MY_USERNAME/tempbackup' 'voip'
echo ' backup_directory_to_usb /home/$MY_USERNAME/tempbackup voip' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2836,7 +2850,7 @@ function create_backup_script {
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'echo "$DATABASE_PASSWORD" > /root/tempmariadb/db' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'chmod 400 /root/tempmariadb/db' >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb '/root/tempmariadb' 'mariadb'
echo 'backup_directory_to_usb /root/tempmariadb mariadb' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
fi
@ -2847,7 +2861,7 @@ function create_backup_script {
echo " mkdir -p $USB_MOUNT/backup/tox" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " cp /etc/tox-bootstrapd.conf /var/lib/tox-bootstrapd" >> /usr/bin/$BACKUP_SCRIPT_NAME
backup_directory_to_usb '/var/lib/tox-bootstrapd' 'tox'
echo ' backup_directory_to_usb /var/lib/tox-bootstrapd tox' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -9851,7 +9865,7 @@ function create_upgrade_script {
echo ' git stash drop' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
echo ' git pull' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
echo " chown -R www-data:www-data /var/www/$HUBZILLA_DOMAIN_NAME/htdocs" >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
echo 'fi' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
echo 'fi' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
echo '' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
echo "if grep -Fxq \"install_gnu_social\" $COMPLETION_FILE; then" >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
echo ' # GNU Social' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
@ -10250,7 +10264,7 @@ function install_ipfs {
fi
apt-get -y install golang libpam0g-dev fuse
if [ ! -d /home/git ]; then
if [ ! -d /home/git ]; then
# add a gogs user account
adduser --disabled-login --gecos 'Gogs' git
@ -10279,7 +10293,7 @@ function install_ipfs {
echo 'export PATH="$PATH:/usr/local/opt/go/libexec/bin";' >> /home/$MY_USERNAME/.bashrc
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.bashrc
fi
go get -u github.com/ipfs/go-ipfs/cmd/ipfs
if [ ! "$?" = "0" ]; then
exit 8242
@ -10317,7 +10331,7 @@ function install_ipfs {
if [ -f /dev/fuse ]; then
chown $MY_USERNAME:$MY_USERNAME /dev/fuse
fi
echo '[Unit]' > /etc/systemd/system/ipfs.service
echo 'Description=IPFS daemon' >> /etc/systemd/system/ipfs.service
echo 'After=syslog.target' >> /etc/systemd/system/ipfs.service
@ -10334,7 +10348,7 @@ function install_ipfs {
echo '' >> /etc/systemd/system/ipfs.service
echo '[Install]' >> /etc/systemd/system/ipfs.service
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/ipfs.service
systemctl enable ipfs
systemctl daemon-reload
systemctl restart ipfs