Created
October 27, 2016 19:18
-
-
Save anonymous/57b55870febb99960ecfa585659ce518 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 | |
# Task runners | |
run_task () { | |
echo " - $1" | |
eval "$2" > /dev/null | |
if [ $? -eq 0 ]; then | |
echo " [done]" | |
else | |
echo " [failed]" | |
exit -1 | |
fi | |
} | |
run_grouped () { | |
echo " - $1" | |
eval "$2" | |
echo " [done]" | |
} | |
run_subtask () { | |
echo " - $1" | |
eval "$2" > /dev/null | |
if [ $? -eq 0 ]; then | |
echo " [done]" | |
else | |
echo " [failed]" | |
exit -1 | |
fi | |
} | |
# Common directories and files | |
encryption_key="$(dirname $0)/keyfile" | |
backup_dir=/var/backup | |
backup_rel=`python -c "import os.path; print os.path.relpath('$backup_dir', '/')"` | |
backup_tar=/var/backup.tgz | |
backup_enc=/var/backup.tgz.enc | |
postgresql_dir=/etc/postgresql/9.4 | |
postgresql_config_original="$postgresql_dir/main/postgresql.conf" | |
postgresql_config_backup="$backup_dir/postgresql.conf" | |
postgresql_hba_original="$postgresql_dir/main/pg_hba.conf" | |
postgresql_hba_backup="$backup_dir/pg_hba.conf" | |
mm_dir=/opt/mattermost | |
mm_config_original="$mm_dir/config/config.json" | |
mm_config_backup="$backup_dir/config.json" | |
nginx_config_original=/etc/nginx/sites-available/mattermost | |
nginx_config_backup="$backup_dir/nginx.conf" | |
ssh_config_original=/etc/ssh/sshd_config | |
ssh_config_backup="$backup_dir/sshd.config" | |
iptables_config_original=/etc/iptables/rules | |
iptables_config_backup="$backup_dir/iptables.rules" | |
cron_backup_original=/etc/cron.daily/complete_backup | |
cron_backup_backup="$backup_dir/complete_backup" | |
cron_certbot_reneval_original=/etc/cron.monthly/certbot_renewal | |
cron_certbot_reneval_backup="$backup_dir/certbot_renewal" | |
network_if_pre_up_iptables_original=/etc/network/if-pre-up.d/iptables | |
network_if_pre_up_iptables_backup="$backup_dir/iptables.if-pre-up" | |
admins_original=/home | |
admins_backup="$backup_dir/admins" | |
database_backup="$backup_dir/db.dump" | |
local_data_original="$mm_dir/data" | |
local_data_backup="$backup_dir/files" | |
certificates_original=/etc/letsencrypt/live/chat.mypage.com | |
certificates_backup="$backup_dir/certificates" | |
s3_new_backup_name="backup-from-$(date '+%Y-%m-%d').tgz.enc" | |
# S3 Upload functions | |
# Should follow this convention: | |
# | |
# aws_upload () { | |
# AWS_ACCESS_KEY_ID=[my access key] \ | |
# AWS_SECRET_ACCESS_KEY=[secret access key] \ | |
# AWS_DEFAULT_REGION=[bucket region] \ | |
# aws s3 cp "$backup_enc" "s3://chat.mypage.com/$s3_new_backup_name" | |
# } | |
source "$(dirname $0)/aws_upload" # should define aws_upload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment