This tool is designed to back up one or more servers to a dedicated machine.
- At least two Linux machines
Before using the various scripts (backup, restore, and checking the date of the last backup), you need to configure the servers to be backed up.
You must have SSH key access configured with the root user on the machine initiating the backups.
Duplicate the ./secrets/var.dev.sh
file and rename it to ./secrets/var.sh
to define the backup configuration for the servers.
Next, set the following information:
NAME
: Server name (Note: this parameter must match the $NAME_CURRENT_SERVER value on the server)IP
: Server's IP addressBACKUP_USER
: User to use for the backup (root is recommended to avoid losing file and folder ownership)FOLDER_BACKUP_SOURCE
: Folder to be backed up on the serverFOLDER_BACKUP_TARGET
: Destination folder for backups on the backup server (initiating the backup) for the current serverFOLDER_BACKUP_GLOBAL
: Parent backup folder (to group backups)FOLDER_BACKUP_PARAMETERS
: Configuration folderNUMBER_OF_DAYS_WITHOUT_WARNING
: Number of days without a backup before receiving notifications
Then, provide the URL of a Discord webhook to notify the administrator during a backup with the variable DISCORD_WEBHOOK_URL
.
NAME_CURRENT_SERVER
: Name of the server to be backed up (the machine's name, which can be equal to $HOST)
You can run the scripts more easily by creating symbolic links for the scripts in /usr/bin
:
sudo ln -s {project-path}/bin/backup.sh /usr/bin/backup
sudo ln -s {project-path}/bin/check-backup-time.sh /usr/bin/check-backup-time
sudo ln -s {project-path}/bin/restore.sh /usr/bin/restore
The following 3 scripts are now available:
# Backup a server (run on the backup server)
sudo backup
# OR
sudo backup ichigo
# Restore a server (run on the backup server)
sudo restore ichigo ichigo ichigo-2023-01-29-22-34-28_1675028068_.tar.gz
# Check the last backup date of the server (run on the server to be backed up)
sudo check-backup-time
It may be useful to run the scripts automatically at regular intervals. Scheduled tasks or cron jobs serve this purpose.
You can configure them on the backup server:
0 1 * * * root backup
And on the server to be backed up:
0 1 * * * root check-backup-time
The tool Crontab Guru can help you configure your cron jobs more easily.
This project is licensed under the GPL License. See the LICENSE file for more details.