This repository contains scripts for performing backup and restoration tasks using a combination of Rclone Mount and Borg. These are Bash scripts for backup/restore of Nextcloud and media servers like Emby, Jellyfin, and Plex, all of which are installed on the same machine.
To perform a full backup of any Nextcloud instance along with a media server like Plex, you will need to back up the following items:
- The Nextcloud file directory (usually /var/www/nextcloud)
- The data directory of Nextcloud (it's recommended not to be located in the web root, e.g., /var/nextcloud_data)
- The Nextcloud database
- The Media Server file directory (usually /var/lib or /var/snap)
With these scripts, all these elements can be included in a backup.
- Important: Before using these scripts, you need to have rclone installed and configured with a backup remote.
- Important: Also, make sure Borg is installed on your system.
- After cloning or downloading the scripts, they need to be set up by running the
setup.sh
script (see below). - If you don't want to use the automated setup, you can also use the
BackupRestore.conf.sample
file as a starting point. Just make sure to rename the file when you're done (cp BackupRestore.conf.sample BackupRestore.conf
). - The configuration file
BackupRestore.conf
has to be located in the same directory as the backup/restore scripts. - If using the scripts for Backup or Restoration of Nextcloud, Plex, or Emby servers, the scripts in this repository assume that the programs were installed via
apt-get
ordpkg
(Media Server).
- Run the following command in a terminal with administrator privileges:
wget https://github.com/raw/edsonsbj/Backup-Restore-Borg-Rclone/main/setup.sh && sudo chmod 700 *.sh && ./sudo setup.sh
- After running the interactive script
setup.sh
, theBackup.sh
andRestore.sh
scripts will be generated based on your selection, along with theBackupRestore.conf
for using the script, and configuring cron. - Important: Check that all files were created and must be in /root/Scripts.
- Important: Check the configuration file to ensure everything was set up correctly (see TODO in the configuration file comments).
- Start using the scripts: See sections Backup and Restore below.
Keep in mind that the configuration file BackupRestore.conf
has to be located in the same directory as the backup/restore scripts, or the configuration will not be found.
- Install Git if it is not already installed.
- Clone this repository or download and unzip the zip file:
git clone https://github.com/edsonsbj/Backup-Restore-Borg-Rclone.git
- Choose the script you want to use for backup and restore and delete the others. Remember that the scripts in the root folder are intended to back up all the files on your system, useful if you are not interested in backing up and restoring Nextcloud, Emby, Jellyfin, and Plex servers.
- Copy the
BackupRestore.conf.sample
file toBackupRestore.conf
, which must be in the same folder as the scripts. - Make the scripts executable with:
chmod 700 *.sh
- Replace the values
--config=/path/user/rclone.conf
andBorg:
in theBackup.service
file with appropriate settings, where--config
corresponds to the location of yourrclone.conf
file, andBorg:/
corresponds to your remote (cloud) to be mounted. - Move the
Backup.service
to the/etc/systemd/system/
folder.
If you chose option 1 >> Backup in the automated setup.sh script, or you cloned the entire repository to use and want to use the scripts contained in the repository root, run the script like this:
sudo ./Backup.sh
If you selected option 3 >> Backup in the automated setup.sh script, or downloaded the Media Server folder, run the script as follows:
sudo ./Backup.sh
Nextcloud & Nextcloud + Media Server
If you chose between options 2 or 4 >> Nextcloud and Nextcloud + Media Server in the automated setup.sh script, or downloaded one of the Nextcloud or Nextcloud + Media Server folders, invoke the script like this:
sudo ./Backup.sh 1
Backup Nextcloud configurations, database, and data folder.
sudo ./Backup.sh 2
Backup Nextcloud configurations and database.
sudo ./Backup.sh 3
Backup Nextcloud configurations and database.
Here, the commands described above remain the same:
sudo ./Backup.sh 4
Backup Nextcloud and Media Server settings.
sudo ./Backup.sh 5
Backup Nextcloud settings, database, and data folder, as well as Media Server settings.
If you chose option 1 >> Backup Restore in the setup.sh automated script, or you cloned the entire repository to use and want to use the scripts contained in the repository root, run the script like this:
sudo ./Restore.sh 2023-07-15
If you selected option 3 >> in the automated setup.sh script, or downloaded the Media Server folder, run the script as follows:
sudo ./Restore.sh 2023-07-15
Nextcloud & Nextcloud + Media Server
If you chose between options 2 or 4 >> Nextcloud and Nextcloud + Media Server in the automated setup.sh script, or downloaded one of the Nextcloud or Nextcloud + Media Server folders, invoke the script like this:
sudo ./Restore.sh 1 2023-07-15
Restore Nextcloud configurations, database, and data folder.
sudo ./Restore.sh 2 2023-07-15
Restore Nextcloud configurations and database.
sudo ./Restore.sh 3 2023-07-15
Restore Nextcloud configurations and database.
Here, the commands described above remain the same:
sudo ./Restore.sh 4 2023-07-15
Restore Nextcloud and Media Server settings.
sudo ./Restore.sh 5 2023-07-15
Restore Nextcloud settings, database, and data folder, as well as Media Server settings.