Last active
February 10, 2018 20:10
-
-
Save harentius/dbe2f991a84adf5615d515d8707c12f0 to your computer and use it in GitHub Desktop.
Backups
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 | |
# Config | |
target_dir="/home/backupper/backup/" | |
target_sync_dir="/home/backupper/Dropbox/" | |
folkprog_assets_base_dir="/home/deploy/projects/folkprog.net/web/assets/" | |
deploy_others_project_dir="/home/deploy-others/projects/" | |
nginx_config_dir="/etc/nginx/" | |
dbs=("folkprog" "mysoul" "gulak" "harry-l") | |
keep_files_days=60 | |
# End Config | |
date_string=`date +%Y-%m-%d-%H-%M` | |
# DBs backup | |
for db in "${dbs[@]}"; do | |
mysqldump -uroot "$db" | gzip -c > "${target_dir}${db}_${date_string}.sql.gz" | |
done | |
# Folkprog files backup | |
tar -czf "${target_dir}folkprog-files.tar.gz" \ | |
"${folkprog_assets_base_dir}images" \ | |
"${folkprog_assets_base_dir}files" \ | |
"${folkprog_assets_base_dir}audios" | |
# 3rd-party sites files backup | |
tar -czf "${target_dir}deploy-others.tar.gz" "$deploy_others_project_dir" | |
# Nginx config backup | |
tar -czf "${target_dir}nginx.gz" "$nginx_config_dir" | |
# Clean old backup files | |
find "$target_dir" -type f -mtime +"$keep_files_days" -exec rm -f {} \; | |
# Packing files to Dropbox sync dir | |
tar -czf "${target_sync_dir}backup_${date_string}.tar.gz" "$target_dir" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment