Skip to content

This repo contains backup strategy docs for our system. Includes tool & process info, installation instructions for Borg Backup & rclone on popular Linux distros. Guides for maintaining & managing backups & restoring data in case of failure.

Notifications You must be signed in to change notification settings

federicociro/backup_strategy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Backup Strategy

This repository contains documentation for the backup strategy used for my Linux systems. It includes information on the tools and processes used for creating and maintaining backups, as well as instructions for restoring from backups in case of a failure or data loss.

GitHub Super-Linter

Table of contents

  1. Tools
  2. Installation
  3. Backup Process
  4. Restoration
  5. Setting up Backup with Systemd
  6. Conclusion
  7. To Do

Tools

  • Borg Backup - A deduplicating backup program that supports compression and authenticated encryption.
  • Rclone - A command line tool for synchronizing files and directories to and from various cloud storage providers.

Installation

Borg Backup

Debian/Ubuntu

sudo apt-get update
sudo apt-get install borgbackup

Fedora/CentOS

sudo dnf install borgbackup

Arch Linux

sudo pacman -S borgbackup

Rclone

Debian/Ubuntu

curl https://rclone.org/install.sh | sudo bash

Fedora/CentOS

curl https://rclone.org/install.sh | sudo bash

Arch Linux

sudo pacman -S rclone

Backup Process

The backup script is built in 3 parts:

  1. Create a new archive using Borg Backup, with the borg create command.
  2. Use rclone to transfer the archive to a remote storage location, with the rclone copy command.
  3. Prune old backups, to keep a specified number of backups and to save space, with the borg prune command.

Restoration

In case of a failure or data loss, backups can be restored using the borg extract command. Detailed instructions for restoring specific files or directories can be found in the Borg Backup documentation. Alternatively, borg mount can be used for temporal restoration.

Setting up Backup with Systemd

In order to run the backup script automatically using systemd, you will need to create two service files: one for the backup service and one for the timer service.

Backup Service

Create a new file named borg-backup.service in the /etc/systemd/system/ directory with the following contents:

[Unit]
Description=Create backup using Borg Backup

[Service]
Type=oneshot
User=root
ExecStart=/usr/local/bin/borg-backup.sh
StandardOutput=file:/var/log/borg-backup.log
StandardError=file:/var/log/borg-backup-error.log
Restart=on-failure

[Install]
WantedBy=multi-user.target
  • Make sure to adjust the paths and user according to your system setup.

Then, enable the service by running:

sudo systemctl enable borg-backup.service

Timer Service

Create a new file named borg-backup.timer in the /etc/systemd/system/ directory with the following contents:

[Unit]
Description=Create backup using Borg Backup

[Timer]
OnCalendar=daily
AccuracySec=1h
Persistent=true

[Install]
WantedBy=timers.target
  • Make sure to adjust the timing of the backup by modifying the OnCalendar value to fit your needs.

Then, enable the timer by running:

sudo systemctl enable borg-backup.timer

You can check the status of the timer and the service by running:

sudo systemctl status borg-backup.timer
sudo systemctl status borg-backup.service

Conclusion

This documentation is intended to serve as a guide for anyone responsible for maintaining and managing backups for our system. It is important to regularly test and verify the backups to ensure that they can be successfully restored in case of a failure or data loss.

To Do

  • Add more features to the script: dry-run option
  • Improve performance of the code
  • Add more comments to the code for better readability
  • Write more detailed documentation
  • Add test cases to ensure reliability
  • Add error handling to the mysqldump command

About

This repo contains backup strategy docs for our system. Includes tool & process info, installation instructions for Borg Backup & rclone on popular Linux distros. Guides for maintaining & managing backups & restoring data in case of failure.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages