Copy gpg keys before restore

This commit is contained in:
Bob Mottram 2015-12-09 15:04:44 +00:00
parent 42e9c7f6b3
commit d454608ec3
1 changed files with 7 additions and 6 deletions

View File

@ -62,12 +62,6 @@ REMOTE_SERVER=$(grep -i "$SERVER_NAME" /home/${ADMIN_USERNAME}/backup.list | awk
REMOTE_SSH_PORT=$(grep -i "$SERVER_NAME" /home/${ADMIN_USERNAME}/backup.list | awk -F ' ' '{print $2}') REMOTE_SSH_PORT=$(grep -i "$SERVER_NAME" /home/${ADMIN_USERNAME}/backup.list | awk -F ' ' '{print $2}')
REMOTE_PASSWORD=$(grep -i "$SERVER_NAME" /home/${ADMIN_USERNAME}/backup.list | awk -F ' ' '{print $3}') REMOTE_PASSWORD=$(grep -i "$SERVER_NAME" /home/${ADMIN_USERNAME}/backup.list | awk -F ' ' '{print $3}')
# Check that a backup key exists
if [ ! -f /etc/ssl/private/backup.key ]; then
echo $'No backup key was found in /etc/ssl/private/backup.key'
exit 84
fi
NOW=$(date +"%Y-%m-%d %H:%M:%S") NOW=$(date +"%Y-%m-%d %H:%M:%S")
echo "$NOW Starting restore from $REMOTE_SERVER" >> /var/log/remotebackups.log echo "$NOW Starting restore from $REMOTE_SERVER" >> /var/log/remotebackups.log
@ -91,6 +85,11 @@ function restore_directory_from_friend {
obnam restore -r $SERVER_DIRECTORY/backup/${2} --to ${1} obnam restore -r $SERVER_DIRECTORY/backup/${2} --to ${1}
} }
function copy_gpg_keys {
echo $"Copying GPG keys from admin user to root"
cp -r /home/$ADMIN_USERNAME/.gnupg /root
}
function restore_database_from_friend { function restore_database_from_friend {
DATABASE_PASSWORD= DATABASE_PASSWORD=
RESTORE_SUBDIR="root" RESTORE_SUBDIR="root"
@ -136,6 +135,8 @@ function restore_database_from_friend {
fi fi
} }
copy_gpg_keys
# Restore configuration files # Restore configuration files
if [ -d $SERVER_DIRECTORY/backup/config ]; then if [ -d $SERVER_DIRECTORY/backup/config ]; then
echo $"Restoring configuration files" echo $"Restoring configuration files"