Skip to content

Instantly share code, notes, and snippets.

@ArnaudValensi
Last active August 14, 2017 21:20
Show Gist options
  • Save ArnaudValensi/5f7207dd0dc970f13630 to your computer and use it in GitHub Desktop.
Save ArnaudValensi/5f7207dd0dc970f13630 to your computer and use it in GitHub Desktop.
#!/bin/bash
# To uncryp:
# $ ccrypt -d --key YourRandomKeyToCrypt fileToUncrypt
SERVER=host0.mindup.io
USER=root
DEST_PATH=/home/backup_arnaud/
KEY=YourRandomKeyToCrypt
BACKUP_NAME=/tmp/$(date +%s)-backup.tar.gz
# Remove files older than 2 days
find /home/srv/docker/gitlab/gitlab/backups/ -mindepth 1 -mtime +2 -delete
tar zcvf $BACKUP_NAME \
/home/srv \
/root/gitlab-docker \
/root/backup \
/etc/nginx
ccrypt -e --key $KEY $BACKUP_NAME
scp $BACKUP_NAME.cpt $USER@$SERVER:$DEST_PATH
# remove older than 10 days
ssh root@$SERVER 'find /srv/backup_arnaud/ -mindepth 1 -mtime +10 -delete'
rm -fr $BACKUP_NAME.cpt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment