I couldn’t easily find a script to automate the snap rocketchat backups so I wrote a quick and dirty one. I thought I’d drop it here in case it helps somebody else out. Please feel free to edit and add your improvements. That’s what the community is for. Go Team!
A couple of things:
This assumes the script is being run as root
This script moves everything from the initial location to a statically-named folder. This folder and the filename could easily be scripted to change.
The move command will only occur on a successful completion of the backup command
Script:
#!/bin/bash
#Variables
backup_destination="/path/to/backup/destination"
backup_location="/path/to/backup/location"
#Start of command section
service snap.rocketchat-server.rocketchat-server stop
snap run rocketchat-server.backupdb &&
mv $backup_location/* $backup_destination
service snap.rocketchat-server.rocketchat-server start
#Clean up everything in destination folder older than 7 days
find $backup_destination/* -mtime +7 -exec rm {} \;