Created
October 27, 2016 19:18
-
-
Save anonymous/174c3b530ee0566faeb5097ed03cdb51 to your computer and use it in GitHub Desktop.
the description for this gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
source "$(dirname $0)/.commons.sh" | |
echo "Restoring Server setup" | |
run_grouped "restoring backup files" "$(cat <<-GROUPED | |
run_subtask "decrypting backup" "$(cat <<-TASK | |
cat "$backup_enc" | mcrypt --decrypt --keyfile "$encryption_key" > "$backup_tar" | |
TASK | |
)" | |
run_subtask "restoring backup directory" "$(cat <<-TASK | |
ls "$backup_dir" > /dev/null || tar -pxvfz "$backup_tar" -C / | |
TASK | |
)" | |
GROUPED | |
)" | |
run_grouped "restoring configs" "$(cat <<-GROUPED | |
run_subtask "Restoring postgres config" "$(cat <<-TASK | |
cp -fp "$postgresql_config_backup" "$postgresql_config_original" && \ | |
cp -fp "$postgresql_hba_backup" "$postgresql_hba_original" | |
TASK | |
)" | |
run_subtask "restoring MatterMost config" "$(cat <<-TASK | |
cp -fp "$mm_config_backup" "$mm_config_original" | |
TASK | |
)" | |
run_subtask "restoring Nginx config" "$(cat <<-TASK | |
cp -fp "$nginx_config_backup" "$nginx_config_original" | |
TASK | |
)" | |
run_subtask "restoring sshd settings" "$(cat <<-TASK | |
cp -fp "$ssh_config_backup" "$ssh_config_original" | |
TASK | |
)" | |
run_subtask "restoring iptables" "$(cat <<-TASK | |
cp -fp "$iptables_config_backup" "$iptables_config_original" | |
TASK | |
)" | |
run_subtask "restoring cron jobs" "$(cat <<-TASK | |
cp -fp "$cron_backup_backup" "$cron_backup_original" && \ | |
cp -fp "$cron_certbot_reneval_backup" "$cron_certbot_reneval_original" | |
TASK | |
)" | |
run_subtask "backing up network jobs" "$(cat <<-TASK | |
cp -fp "$network_if_pre_up_iptables_backup" "$network_if_pre_up_iptables_original" | |
TASK | |
)" | |
GROUPED | |
)" | |
run_task "restoring admins" "$(cat <<-TASK | |
cp -rfp "$admins_backup"/* "$admins_original" | |
TASK | |
)" | |
run_grouped "restoring data" "$(cat <<-GROUPED | |
run_subtask "restoring database" "$(cat <<-TASK | |
sudo -u postgres psql --set ON_ERROR_STOP=on mattermost < "$database_backup" 2> /dev/null | |
TASK | |
)" | |
run_subtask "restoring local data" "$(cat <<-TASK | |
cp -rfp "$local_data_backup"/* "$local_data_original" | |
TASK | |
)" | |
run_subtask "restoring certificates" "$(cat <<-TASK | |
if [ ! -d "$certificates_original" ]; then | |
mkdir "$certificates_original" -p > /dev/null | |
fi | |
cp -rfp "$certificates_backup"/* "$certificates_original" | |
TASK | |
)" | |
GROUPED | |
)" | |
echo "[done]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment