Enforce a global client name for obnam backups
Otherwise you can't restore directories to a system with a different domain name
This commit is contained in:
parent
6316078412
commit
a50c9c6f63
|
@ -50,7 +50,7 @@ source $PROJECT_INSTALL_DIR/${PROJECT_NAME}-vars
|
|||
UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
|
||||
for f in $UTILS_FILES
|
||||
do
|
||||
source $f
|
||||
source $f
|
||||
done
|
||||
|
||||
USB_DRIVE=/dev/sdb1
|
||||
|
@ -92,13 +92,6 @@ function copy_gpg_keys {
|
|||
cp -r /home/$ADMIN_USERNAME/.gnupg /root
|
||||
}
|
||||
|
||||
function restore_directory_from_usb {
|
||||
if [ ! -d ${1} ]; then
|
||||
mkdir ${1}
|
||||
fi
|
||||
obnam restore -r $USB_MOUNT/backup/${2} --to ${1}
|
||||
}
|
||||
|
||||
function restore_config {
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'config' ]]; then
|
||||
|
@ -320,14 +313,16 @@ function restore_procmail {
|
|||
echo $"Restoring procmail settings for $USERNAME"
|
||||
temp_restore_dir=/root/tempprocmail
|
||||
restore_directory_from_usb $temp_restore_dir procmail/$USERNAME
|
||||
cp -f $temp_restore_dir/home/$USERNAME/tempbackup/.procmailrc /home/$USERNAME/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
if [ -d $temp_restore_dir ]; then
|
||||
cp -f $temp_restore_dir/home/$USERNAME/tempbackup/.procmailrc /home/$USERNAME/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
rm -rf $temp_restore_dir
|
||||
set_user_permissions
|
||||
backup_unmount_drive
|
||||
exit 276
|
||||
fi
|
||||
rm -rf $temp_restore_dir
|
||||
set_user_permissions
|
||||
backup_unmount_drive
|
||||
exit 276
|
||||
fi
|
||||
rm -rf $temp_restore_dir
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
|
|
@ -39,7 +39,7 @@ export TEXTDOMAINDIR="/usr/share/locale"
|
|||
UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
|
||||
for f in $UTILS_FILES
|
||||
do
|
||||
source $f
|
||||
source $f
|
||||
done
|
||||
|
||||
SERVER_NAME=$1
|
||||
|
@ -96,13 +96,6 @@ fi
|
|||
# MariaDB password
|
||||
DATABASE_PASSWORD=$(cat /root/dbpass)
|
||||
|
||||
function restore_directory_from_friend {
|
||||
if [ ! -d ${1} ]; then
|
||||
mkdir ${1}
|
||||
fi
|
||||
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
|
||||
|
|
|
@ -218,6 +218,13 @@ function backup_database_local {
|
|||
fi
|
||||
}
|
||||
|
||||
function set_obnam_client_name {
|
||||
# obnam can backup multiple machines with different domain names to
|
||||
# a repository. To be able to restore directories from different
|
||||
# machines we need to enforce a single client name for all backups
|
||||
echo "client-name = ${PROJECT_NAME}" > /etc/obnam.conf
|
||||
}
|
||||
|
||||
function backup_directory_to_usb {
|
||||
if [ ! -d ${1} ]; then
|
||||
echo $"WARNING: directory does not exist: ${1}"
|
||||
|
@ -233,6 +240,7 @@ function backup_directory_to_usb {
|
|||
if [ ! -d $USB_MOUNT/backup/${2} ]; then
|
||||
mkdir -p $USB_MOUNT/backup/${2}
|
||||
fi
|
||||
set_obnam_client_name
|
||||
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}
|
||||
if [[ $ENABLE_BACKUP_VERIFICATION == "yes" ]]; then
|
||||
|
@ -268,6 +276,22 @@ function backup_directory_to_usb {
|
|||
fi
|
||||
}
|
||||
|
||||
function restore_directory_from_usb {
|
||||
if [ ! -d ${1} ]; then
|
||||
mkdir ${1}
|
||||
fi
|
||||
set_obnam_client_name
|
||||
obnam restore -r $USB_MOUNT/backup/${2} --to ${1}
|
||||
}
|
||||
|
||||
function restore_directory_from_friend {
|
||||
if [ ! -d ${1} ]; then
|
||||
mkdir ${1}
|
||||
fi
|
||||
set_obnam_client_name
|
||||
obnam restore -r $SERVER_DIRECTORY/backup/${2} --to ${1}
|
||||
}
|
||||
|
||||
function backup_database_to_usb {
|
||||
database_name=$1
|
||||
backup_database_local $database_name
|
||||
|
@ -297,6 +321,7 @@ function backup_directory_to_friend {
|
|||
if [ ! -d $SERVER_DIRECTORY/backup/${2} ]; then
|
||||
mkdir -p $SERVER_DIRECTORY/backup/${2}
|
||||
fi
|
||||
set_obnam_client_name
|
||||
obnam force-lock -r $SERVER_DIRECTORY/backup/${2} --encrypt-with ${ADMIN_BACKUP_KEY_ID} ${1}
|
||||
obnam backup -r $SERVER_DIRECTORY/backup/${2} --encrypt-with ${ADMIN_BACKUP_KEY_ID} ${1}
|
||||
if [[ $ENABLE_VERIFICATION == "yes" ]]; then
|
||||
|
|
Loading…
Reference in New Issue