restic >=v0.9.6zstd: for mysql backups
restic is a command-line tool for making backups.
Ubuntu:
$ apt-get install restic && apt-get install git
sudo apt-get update && sudo apt-get install -y software-properties-common && sudo add-apt-repository -y ppa:copart/restic && sudo apt-get update && sudo apt-get install -y restic gitCentOS:
$ yum install yum-plugin-copr && yum copr enable copart/restic && yum install restic && yum install git
sudo apt-get update && sudo apt-get install -y software-properties-common && sudo add-apt-repository -y ppa:copart/restic && sudo apt-get update && sudo apt-get install -y restic gitTip: The steps in this section will instruct you to copy files from this repo to system directories.
$ git clone https://github.com/payrequestio/directadmin-vps-backup.git
$ cd directadmin-vps-backup
$ sudo make installPut these files in /etc/restic/:
env.sh: Fill this file out with your S3 bucket settings. The reason for putting these in a separate file is that it can be used also for you to simply source, when you want to issue some restic commands. For example:
$ source /etc/restic/env.sh
$ restic snapshots # You don't have to supply all parameters like --repo, as they are now in your environment!Now we must initialize the repository on the remote end:
source /etc/restic/env.sh && restic initPut this file in /usr/local/sbin:
directadmin-vps-backup.sh: A script that defines how to run the backup. Edit this file to respect your needs in terms of backup which paths to backup, retention (number of backups to save), etc.
Put this file in /:
.backup_exclude: A list of file pattern paths to exclude from you backups, files that just occupy storage space, backup-time, network and money.
Now see if the backup itself works, by running
$ /usr/local/sbin/directadmin-vps-backup.sh
$ restic snapshotsNow we can do the modern version of a cron-job, a systemd service + timer, to run the backup every day!
Put these files in /etc/systemd/system/:
directadmin-vps-backup.service: A service that calls the backup script.directadmin-vps-backup.timer: A timer that starts the backup every day.
Now simply enable the timer with:
$ systemctl start directadmin-vps-backup.timer
$ systemctl enable directadmin-vps-backup.timerYou can see when your next backup is scheduled to run with
$ systemctl list-timers | grep directadmin-vps-backupand see the status of a currently running backup with
$ systemctl status directadmin-vps-backupor start a backup manually
$ systemctl start directadmin-vps-backupYou can follow the backup stdout output live as backup is running with:
$ journalctl -f -u directadmin-vps-backup.service(skip -f to see all backups that has run)