Last active
March 27, 2021 21:14
-
-
Save thisni1s/23276990d048ea9facbe05e6e688e595 to your computer and use it in GitHub Desktop.
Mailcow backup script w/ PGP and SCP
This file contains hidden or 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 | |
NOW=$(date '+%d-%m-%y') | |
BDIR=/opt/mailcow-dockerized/backups/backup-${NOW} | |
mkdir $BDIR | |
MAILCOW_BACKUP_LOCATION=$BDIR /opt/mailcow-dockerized/helper-scripts/backup_and_restore.sh backup all | |
cp /opt/mailcow-dockerized/mailcow.conf $BDIR/. | |
tar -czvf /opt/mailcow-dockerized/backups/backup-${NOW}.tar.gz $BDIR | |
gpg --encrypt --sign -r [email protected] -o /opt/mailcow-dockerized/backups/backup-${NOW}.tar.gz.gpg --passphrase-file /path/to/file --batch --pinentry-mode loopback /opt/mailcow-dockerized/backups/backup-${NOW}.tar.gz | |
scp -P 1337 /opt/mailcow-dockerized/backups/backup-${NOW}.tar.gz.gpg user@host:/home/user/backups/. | |
rm /opt/mailcow-dockerized/backups/backup-${NOW}.tar.gz.gpg | |
rm /opt/mailcow-dockerized/backups/backup-${NOW}.tar.gz | |
rm -rf $BDIR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment