Backup gogs repositories

This commit is contained in:
Bob Mottram 2015-03-19 21:13:11 +00:00
parent d8f6ce0df9
commit 52767d00c7
1 changed files with 45 additions and 2 deletions

View File

@ -1733,8 +1733,8 @@ function create_backup_script {
echo "if [ ! -d $USB_MOUNT/backup/gogs ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/gogs" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "if [ ! -d $USB_MOUNT/backup/gogs2 ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/gogs2" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "if [ ! -d $USB_MOUNT/backup/gogsrepos ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/gogsrepos" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "if [ ! -d $USB_MOUNT/backup/gogsdata ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/gogsdata" >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -1769,6 +1769,13 @@ function create_backup_script {
echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' exit 632' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'echo "Obtaining Gogs repos backup"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "rsyncrypto -v -r /home/git/gogs-repositories $USB_MOUNT/backup/gogsrepos $USB_MOUNT/backup/gogsrepos.keys $BACKUP_CERTIFICATE" >> /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 ' exit 6784' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
fi
if grep -Fxq "install_wiki" $COMPLETION_FILE; then
@ -2116,6 +2123,7 @@ function create_restore_script {
get_mariadb_gnusocial_admin_password
get_mariadb_redmatrix_admin_password
get_mariadb_owncloud_admin_password
get_mariadb_git_admin_password
echo '#!/bin/bash' > /usr/bin/$RESTORE_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -2580,8 +2588,20 @@ function create_restore_script {
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' exit 981' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring Gogs repos"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! -d /root/tempgogsrepos ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' mkdir /root/tempgogsrepos' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rsyncrypto -v -d -r $USB_MOUNT/backup/gogsrepos /root/tempgogsrepos $USB_MOUNT/backup/gogsrepos.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " cp -r /root/tempgogsrepos/usb/backup/gogsrepos/git/gog-repositories/* /home/git/gogs-repositories/" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' exit 67574' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/tempgogs' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/tempgogsdata' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/tempgogsrepos' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
fi
@ -3006,6 +3026,9 @@ function backup_to_friends_servers {
echo 'if [ ! -d $SERVER_DIRECTORY/backup/gogsdata ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' mkdir -p $SERVER_DIRECTORY/backup/gogsdata' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo 'if [ ! -d $SERVER_DIRECTORY/backup/gogsrepos ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' mkdir -p $SERVER_DIRECTORY/backup/gogsrepos' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "if [ ! -d /root/tempgogsdata ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " mkdir -p /root/tempgogsdata" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
@ -3041,6 +3064,15 @@ function backup_to_friends_servers {
echo "$MY_EMAIL_ADDRESS" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' exit 76547' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo 'echo "Obtaining Gogs repos backup"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n 'rsyncrypto -v -r /home/git/gogs-repositories $SERVER_DIRECTORY/backup/gogsrepos $SERVER_DIRECTORY/backup/gogsrepos.keys ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "$BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo 'if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' # Send a warning email' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n ' echo "Unable to encrypt gogs repos (/home/git/gogs-repositories)" | mail -s "Freedombone backup to friends" ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "$MY_EMAIL_ADDRESS" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' exit 454637' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
fi
@ -3923,8 +3955,19 @@ function restore_from_friend {
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' exit 5885' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' echo "Restoring Gogs repos"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! -d /root/tempgogsrepos ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' mkdir /root/tempgogsrepos' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/gogsrepos /root/tempgogsrepos $SERVER_DIRECTORY/backup/gogsrepos.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " cp -r /root/tempgogsrepos/remoterestore/backup/gogsrepos/git/gogs-repositories/* /home/git/gogs-repositories/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' exit 7649' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' rm -rf /root/tempgogs' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' rm -rf /root/tempgogsdata' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' rm -rf /root/tempgogsrepos' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
fi