Created
June 13, 2020 10:58
-
-
Save MarcoBuster/ac043e86c0af7828d704b3af6f73ff7c to your computer and use it in GitHub Desktop.
Docker redis and postgres backup via Telegram
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 | |
FILENAME="history/$(date +%Y-%m-%d"_"%H-%M-%s)".tar.gz | |
backup_redis () { | |
/usr/bin/docker cp $1:/data/dump.rdb latest/$1.rdb | |
} | |
backup_postgres () { | |
/usr/bin/docker exec -t $1 pg_dumpall -c -U postgres > latest/$1.sql | |
} | |
rm latest/* | |
backup_redis my_redis_container | |
backup_postgres my_postgres_contaienr | |
# .. | |
cd history/ | |
rm `ls -t | awk 'NR>10'` | |
cd .. | |
/bin/tar cvf $FILENAME latest/ | |
/usr/bin/python3 tgsend.py -f $FILENAME # https://gist.github.com/MarcoBuster/8e4f6db4dc4ba5eb5640224b518d7c7e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment