Created
October 27, 2016 19:18
-
-
Save anonymous/4aa9fd19430e708ab76bc42abfa052da 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 "Backing up Server" | |
if [ ! -d $backup_dir ]; then | |
mkdir $backup_dir -p > /dev/null | |
fi | |
run_grouped "backing up configs" "$(cat <<-GROUPED | |
run_subtask "backing up postgres config" "$(cat <<-TASK | |
cp -fp "$postgresql_config_original" "$postgresql_config_backup" && \ | |
cp -fp "$postgresql_hba_original" "$postgresql_hba_backup" | |
TASK | |
)" | |
run_subtask "backing up MatterMost config" "$(cat <<-TASK | |
cp -fp "$mm_config_original" "$mm_config_backup" | |
TASK | |
)" | |
run_subtask "backing up Nginx config" "$(cat <<-TASK | |
cp -fp "$nginx_config_original" "$nginx_config_backup" | |
TASK | |
)" | |
run_subtask "backing up sshd settings" "$(cat <<-TASK | |
cp -fp "$ssh_config_original" "$ssh_config_backup" | |
TASK | |
)" | |
run_subtask "backing up iptables" "$(cat <<-TASK | |
cp -fp "$iptables_config_original" "$iptables_config_backup" | |
TASK | |
)" | |
run_subtask "backing up cron jobs" "$(cat <<-TASK | |
cp -fp "$cron_backup_original" "$cron_backup_backup" && \ | |
cp -fp "$cron_certbot_reneval_original" "$cron_certbot_reneval_backup" | |
TASK | |
)" | |
run_subtask "backing up network jobs" "$(cat <<-TASK | |
cp -fp "$network_if_pre_up_iptables_original" "$network_if_pre_up_iptables_backup" | |
TASK | |
)" | |
GROUPED | |
)" | |
run_task "backing up admins" "$(cat <<-TASK | |
if [ ! -d "$backup_dir/admins" ]; then | |
mkdir "$backup_dir/admins" -p > /dev/null | |
fi | |
cp -rfp "$admins_original"/* "$admins_backup" | |
TASK | |
)" | |
run_grouped "backing up data" "$(cat <<-GROUPED | |
run_subtask "backing up database" "$(cat <<-TASK | |
sudo -u postgres pg_dump mattermost > "$database_backup" | |
TASK | |
)" | |
run_subtask "backing up local data" "$(cat <<-TASK | |
if [ ! -d "$local_data_backup" ]; then | |
mkdir "$local_data_backup" -p > /dev/null | |
fi | |
cp -rfp "$local_data_original"/* "$local_data_backup" | |
TASK | |
)" | |
run_subtask "backing up certificates" "$(cat <<-TASK | |
if [ ! -d "$certificates_backup" ]; then | |
mkdir "$certificates_backup" -p > /dev/null | |
fi | |
cp -rfp "$certificates_original"/* "$certificates_backup" | |
TASK | |
)" | |
GROUPED | |
)" | |
run_grouped "upload backup to S3" "$(cat <<-GROUPED | |
run_subtask "compressing backup" "$(cat <<-TASK | |
tar -pcvzf "$backup_tar" -C / "$backup_rel" | |
TASK | |
)" | |
run_subtask "encrypting backup" "$(cat <<-TASK | |
cat "$backup_tar" | mcrypt --keyfile "$encryption_key" > "$backup_enc" 2> /dev/null | |
TASK | |
)" | |
run_subtask "uploading backup" "$(cat <<-TASK | |
mjk_upload && jelz_upload | |
TASK | |
)" | |
GROUPED | |
)" | |
echo "[done]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment