Create directories if needed
This commit is contained in:
parent
580d3cec40
commit
6764a366af
|
@ -137,6 +137,9 @@ function backup_directory_to_usb {
|
|||
exit 6
|
||||
fi
|
||||
MY_BACKUP_KEY_ID=$(gpg --list-keys "$ADMIN_NAME (backup key)" | grep 'pub ' | awk -F ' ' '{print $2}' | awk -F '/' '{print $2}')
|
||||
if [ ! -d $USB_MOUNT/backup/${2} ]; then
|
||||
mkdir -p $USB_MOUNT/backup/${2}
|
||||
fi
|
||||
obnam force-lock -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
|
||||
obnam backup -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
|
||||
obnam forget --keep=30d -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID
|
||||
|
@ -164,36 +167,24 @@ for d in /home/*/ ; do
|
|||
# Backup any gpg keys
|
||||
if [ -d /home/$USERNAME/.gnupg ]; then
|
||||
echo $"Backing up gpg keys for $USERNAME"
|
||||
if [ ! -d $USB_MOUNT/backup/gnupg/$USERNAME ]; then
|
||||
mkdir -p $USB_MOUNT/backup/gnupg/$USERNAME
|
||||
fi
|
||||
backup_directory_to_usb /home/$USERNAME/.gnupg gnupg/$USERNAME
|
||||
fi
|
||||
|
||||
# Backup any personal settings
|
||||
if [ -d /home/$USERNAME/personal ]; then
|
||||
echo $"Backing up personal settings for $USERNAME"
|
||||
if [ ! -d $USB_MOUNT/backup/personal/$USERNAME ]; then
|
||||
mkdir -p $USB_MOUNT/backup/personal/$USERNAME
|
||||
fi
|
||||
backup_directory_to_usb /home/$USERNAME/personal personal/$USERNAME
|
||||
fi
|
||||
|
||||
# Backup ssh keys
|
||||
if [ -d /home/$USERNAME/.ssh ]; then
|
||||
echo $"Backing up ssh keys for $USERNAME"
|
||||
if [ ! -d $USB_MOUNT/backup/ssh/$USERNAME ]; then
|
||||
mkdir -p $USB_MOUNT/backup/ssh/$USERNAME
|
||||
fi
|
||||
backup_directory_to_usb /home/$USERNAME/.ssh ssh/$USERNAME
|
||||
fi
|
||||
|
||||
# Backup user configs
|
||||
if [ -d /home/$USERNAME/.config ]; then
|
||||
echo $"Backing up config files for $USERNAME"
|
||||
if [ ! -d $USB_MOUNT/backup/config/$USERNAME ]; then
|
||||
mkdir -p $USB_MOUNT/backup/config/$USERNAME
|
||||
fi
|
||||
backup_directory_to_usb /home/$USERNAME/.config config/$USERNAME
|
||||
fi
|
||||
|
||||
|
@ -207,9 +198,6 @@ for d in /home/*/ ; do
|
|||
if [ -f /etc/Muttrc ]; then
|
||||
cp /etc/Muttrc /home/$USERNAME/tempbackup
|
||||
fi
|
||||
if [ ! -d $USB_MOUNT/backup/mutt/$USERNAME ]; then
|
||||
mkdir -p $USB_MOUNT/backup/mutt/$USERNAME
|
||||
fi
|
||||
backup_directory_to_usb /home/$USERNAME/tempbackup mutt/$USERNAME
|
||||
fi
|
||||
|
||||
|
@ -221,18 +209,12 @@ for d in /home/*/ ; do
|
|||
fi
|
||||
tar -czvf /root/tempbackupemail/$USERNAME/maildir.tar.gz /home/$USERNAME/Maildir
|
||||
echo $"Backing up emails for $USERNAME"
|
||||
if [ ! -d $USB_MOUNT/backup/mail/$USERNAME ]; then
|
||||
mkdir -p $USB_MOUNT/backup/mail/$USERNAME
|
||||
fi
|
||||
backup_directory_to_usb /root/tempbackupemail/$USERNAME mail/$USERNAME
|
||||
fi
|
||||
|
||||
# Backup spamassassin
|
||||
if [ -d /home/$USERNAME/.spamassassin ]; then
|
||||
echo $"Backing up spamassassin settings for $USERNAME"
|
||||
if [ ! -d $USB_MOUNT/backup/spamassassin/$USERNAME ]; then
|
||||
mkdir -p $USB_MOUNT/backup/spamassassin/$USERNAME
|
||||
fi
|
||||
backup_directory_to_usb /home/$USERNAME/.spamassassin spamassassin/$USERNAME
|
||||
fi
|
||||
|
||||
|
@ -243,9 +225,6 @@ for d in /home/*/ ; do
|
|||
mkdir -p /home/$USERNAME/tempbackup
|
||||
fi
|
||||
cp /home/$USERNAME/.procmailrc /home/$USERNAME/tempbackup
|
||||
if [ ! -d $USB_MOUNT/backup/procmail/$USERNAME ]; then
|
||||
mkdir -p $USB_MOUNT/backup/procmail/$USERNAME
|
||||
fi
|
||||
backup_directory_to_usb /home/$USERNAME/tempbackup procmail/$USERNAME
|
||||
fi
|
||||
|
||||
|
@ -300,12 +279,6 @@ fi
|
|||
|
||||
# backup gogs
|
||||
if [ -d /home/git/go/src/github.com/gogits ]; then
|
||||
if [ ! -d $USB_MOUNT/backup/gogsrepos ]; then
|
||||
mkdir -p $USB_MOUNT/backup/gogsrepos
|
||||
fi
|
||||
if [ ! -d $USB_MOUNT/backup/gogsssh ]; then
|
||||
mkdir -p $USB_MOUNT/backup/gogsssh
|
||||
fi
|
||||
backup_database gogs
|
||||
backup_directory_to_usb /root/tempgogsdata gogsdata
|
||||
echo $"Obtaining Gogs settings backup"
|
||||
|
@ -319,12 +292,6 @@ fi
|
|||
|
||||
# Backup wiki
|
||||
if [ -d /etc/dokuwiki ]; then
|
||||
if [ ! -d $USB_MOUNT/backup/wiki ]; then
|
||||
mkdir -p $USB_MOUNT/backup/wiki
|
||||
fi
|
||||
if [ ! -d $USB_MOUNT/backup/wiki2 ]; then
|
||||
mkdir -p $USB_MOUNT/backup/wiki2
|
||||
fi
|
||||
echo $"Obtaining wiki data backup"
|
||||
backup_directory_to_usb /var/lib/dokuwiki wiki
|
||||
backup_directory_to_usb /etc/dokuwiki wiki2
|
||||
|
@ -334,9 +301,6 @@ fi
|
|||
if grep -q "Blog domain" $COMPLETION_FILE; then
|
||||
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
|
||||
if [ -d /var/www/${FULLBLOG_DOMAIN_NAME} ]; then
|
||||
if [ ! -d $USB_MOUNT/backup/blog ]; then
|
||||
mkdir -p $USB_MOUNT/backup/blog
|
||||
fi
|
||||
echo $"Obtaining blog backup"
|
||||
backup_directory_to_usb /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs blog
|
||||
else
|
||||
|
@ -349,45 +313,30 @@ fi
|
|||
# Backup certificates
|
||||
if [ -d /etc/ssl ]; then
|
||||
echo $"Backing up certificates"
|
||||
if [ ! -d $USB_MOUNT/backup/ssl ]; then
|
||||
mkdir -p $USB_MOUNT/backup/ssl
|
||||
fi
|
||||
backup_directory_to_usb /etc/ssl ssl
|
||||
fi
|
||||
|
||||
# Backup the public mailing list
|
||||
if [ -d /var/spool/mlmmj ]; then
|
||||
echo $"Backing up the public mailing list"
|
||||
if [ ! -d $USB_MOUNT/backup/mailinglist ]; then
|
||||
mkdir -p $USB_MOUNT/backup/mailinglist
|
||||
fi
|
||||
backup_directory_to_usb /var/spool/mlmmj mailinglist
|
||||
fi
|
||||
|
||||
# Backup xmpp settings
|
||||
if [ -d /var/lib/prosody ]; then
|
||||
echo $"Backing up the XMPP settings"
|
||||
if [ ! -d $USB_MOUNT/backup/xmpp ]; then
|
||||
mkdir -p $USB_MOUNT/backup/xmpp
|
||||
fi
|
||||
backup_directory_to_usb /var/lib/prosody xmpp
|
||||
fi
|
||||
|
||||
# Backup web sites
|
||||
if [ -d /etc/nginx ]; then
|
||||
echo $"Backing up web settings"
|
||||
if [ ! -d $USB_MOUNT/backup/web ]; then
|
||||
mkdir -p $USB_MOUNT/backup/web
|
||||
fi
|
||||
backup_directory_to_usb /etc/nginx/sites-available web
|
||||
fi
|
||||
|
||||
# Backup admin user README file
|
||||
if [ -f /home/$ADMIN_USERNAME/README ]; then
|
||||
echo $"Backing up README"
|
||||
if [ ! -d $USB_MOUNT/backup/readme ]; then
|
||||
mkdir -p $USB_MOUNT/backup/readme
|
||||
fi
|
||||
if [ ! -d /home/$ADMIN_USERNAME/tempbackup ]; then
|
||||
mkdir -p /home/$ADMIN_USERNAME/tempbackup
|
||||
fi
|
||||
|
@ -398,18 +347,12 @@ fi
|
|||
# Backup IPFS
|
||||
if [ -d /home/$ADMIN_USERNAME/.ipfs ]; then
|
||||
echo $"Backing up IPFS"
|
||||
if [ ! -d $USB_MOUNT/backup/ipfs ]; then
|
||||
mkdir -p $USB_MOUNT/backup/ipfs
|
||||
fi
|
||||
backup_directory_to_usb /home/$ADMIN_USERNAME/.ipfs ipfs
|
||||
fi
|
||||
|
||||
# Backup DLNA cache
|
||||
if [ -d /var/cache/minidlna ]; then
|
||||
echo $"Backing up DLNA cache"
|
||||
if [ ! -d $USB_MOUNT/backup/dlna ]; then
|
||||
mkdir -p $USB_MOUNT/backup/dlna
|
||||
fi
|
||||
backup_directory_to_usb /var/cache/minidlna dlna
|
||||
fi
|
||||
|
||||
|
@ -422,17 +365,11 @@ if [ -f /etc/mumble-server.ini ]; then
|
|||
cp -f /etc/mumble-server.ini /root/tempvoipbackup
|
||||
cp -f /var/lib/mumble-server/mumble-server.sqlite /root/tempvoipbackup
|
||||
cp -f /etc/sipwitch.conf /root/tempvoipbackup
|
||||
if [ ! -d $USB_MOUNT/backup/voip ]; then
|
||||
mkdir -p $USB_MOUNT/backup/voip
|
||||
fi
|
||||
backup_directory_to_usb /root/tempvoipbackup voip
|
||||
fi
|
||||
|
||||
# MariaDB settings
|
||||
if [ ${#DATABASE_PASSWORD} -gt 1 ]; then
|
||||
if [ ! -d $USB_MOUNT/backup/mariadb ]; then
|
||||
mkdir -p $USB_MOUNT/backup/mariadb
|
||||
fi
|
||||
if [ ! -d /root/tempmariadb ]; then
|
||||
mkdir /root/tempmariadb
|
||||
fi
|
||||
|
@ -452,9 +389,6 @@ fi
|
|||
# Backup Tox node settings
|
||||
if [ -d /var/lib/tox-bootstrapd ]; then
|
||||
echo $"Backing up Tox node settings"
|
||||
if [ ! -d $USB_MOUNT/backup/tox ]; then
|
||||
mkdir -p $USB_MOUNT/backup/tox
|
||||
fi
|
||||
cp /etc/tox-bootstrapd.conf /var/lib/tox-bootstrapd
|
||||
if [ -d /var/lib/tox-bootstrapd/Maildir ]; then
|
||||
rm -rf /var/lib/tox-bootstrapd/Maildir
|
||||
|
|
Loading…
Reference in New Issue