Last active
December 20, 2015 18:28
-
-
Save kzaitsev/6175604 to your computer and use it in GitHub Desktop.
zbackup
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
sshfs backup_name.your-backup.de: /backups | |
for dir in /home/deploy/apps/* | |
do | |
if [ -d "$dir/current" ]; then | |
if [ ! -d "/backups/$(echo $dir | sed 's#.*/##')" ]; then | |
mkdir "/backups/$(echo $dir | sed 's#.*/##')" | |
fi | |
if [ -f "$dir/shared/config/database.yml" ]; then | |
sudo -u deploy -H bash -c "source /usr/local/rvm/scripts/rvm && cd $dir/current && pwd && bundle exec rake db:dump RAILS_ENV=production" | |
if [ -f "$dir/current/db/data.yml" ]; then | |
if [ ! -d "/backups/$(echo $dir | sed 's#.*/##')/database" ]; then | |
zbackup init --non-encrypted "/backups/$(echo $dir | sed 's#.*/##')/database" | |
fi | |
tar -c "$dir/current/db/data.yml" | zbackup backup /backups/$(echo $dir | sed 's#.*/##')/database/backups/backup-`date '+%Y-%m-%d'` | |
fi | |
fi | |
if [ -d "$dir/shared/system" ]; then | |
if [ ! -d "/backups/$(echo $dir | sed 's#.*/##')/system" ]; then | |
zbackup init --non-encrypted "/backups/$(echo $dir | sed 's#.*/##')/system" | |
fi | |
tar -c "$dir/shared/system" | zbackup backup /backups/$(echo $dir | sed 's#.*/##')/system/backups/backup-`date '+%Y-%m-%d'` | |
fi | |
fi | |
done | |
umount /backups |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment