Last active
September 18, 2022 08:20
-
-
Save jfqd/fa11f5d690124d7f4863d240a1526ca2 to your computer and use it in GitHub Desktop.
Save Rocket.Chat Backup to another host and preserve the last 7 versions
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
#!/usr/bin/bash | |
# You may create a crontab entry like: | |
# 0 1 * * * /usr/local/bin/rc-backup | |
# and change the following four vars: | |
_URL="rc.example.com" | |
_USR="rc-backup" | |
_PWD="<long-secure-password>" | |
_CWD="/home/jfqd/rc-backup" | |
YESTERDAY=$(TZ=GMT+24 date '+%Y%m%d') | |
cd "%{_CWD} | |
curl -s -LO -u "${_USR}:${_PWD}" https://${_URL}/rc-backup/${YESTERDAY}_rocketchat.mongodump.tar.bz2 | |
curl -s -LO -u "${_USR}:${_PWD}" https://${_URL}/rc-backup/${YESTERDAY}_rocketchat.mongodump.tar.bz2.shasum | |
curl -s -LO -u "${_USR}:${_PWD}" https://${_URL}/rc-backup/${YESTERDAY}_rocketchat_upload.tar.bz2 | |
curl -s -LO -u "${_USR}:${_PWD}" https://${_URL}/rc-backup/${YESTERDAY}_rocketchat_upload.tar.bz2.shasum | |
ls -1dt ./*_rocketchat.mongodump.tar.bz2 | tail -n +8 | xargs rm -rf || true | |
ls -1dt ./*_rocketchat_upload.tar.bz2 | tail -n +8 | xargs rm -rf || true | |
ls -1dt ./*_rocketchat.mongodump.tar.bz2.shasum | tail -n +8 | xargs rm -rf || true | |
ls -1dt ./*_rocketchat_upload.tar.bz2.shasum | tail -n +8 | xargs rm -rf || true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment