Skip to content

This program automates a nextcloud instance's backup with S3 Glacier upload. Daily archives are made with weekly, monthly and yearly rotations. The idea is to keep useful archives at significant times.

ngasull/nextcloud-s3-glacier-backup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nextcloud S3 Glacier cron Archiver

This program automates a nextcloud instance's backup with S3 Glacier upload. Daily archives are made with weekly, monthly and yearly rotations. The idea is to keep useful archives at significant times.

Prerequisites

This program is made for nextcloud-snap instances as it relies on nextcloud.export tool.

It depends on jq, openssl, parallel and xz-utils (for optimal compression). On debian-based distros:

sudo apt install jq openssl parallel xz-utils

Finally, it uses AWS official client so please refer to their documentation for installation.

Installation

Make sure AWS CLI is properly configured with your credentials.

Then clone this repository and setup a cron job for a daily backup.

You can edit root's crontab with this command:

sudo crontab -e

And then add the following cron line for the root user:

0 5 * * * env "PATH=$PATH:/path/to/aws/bin:/snap/bin" /path/to/nextcloud-to-glacier/nextcloud-cron-backup-aws.sh &>> /path/to/nextcloud-to-glacier/nextcloud-to-glacier.log

NB:

  • /path/to/aws/bin depends on your installation. For me it was /home/myuser/.local/bin
  • Make sure to replace /path/to/nextcloud-s3-glacier-backup by an absolute path without ~.
  • Make sure you also did the above for the log file (second occurence in the cron line)
  • "5" on the cron line hold the hour position and means the script runs everyday at 5am. You can obviously adjust it! :)

Backup restoration

This part has not been automated, however you can download the glacier archive manually and restore it with the following steps:

tar -xf backup.tar.xz
# Either use nextcloud-snap's importer
nextcloud.import extracted_backup_folder
# Or import desired data manually from the folder, for ex.:
nextcloud.mysql -u nextcloud -p nextcloud < extracted_backup_folder/database.sql
# Password can be looked up in extracted_backup_folder/config.php

Credits

AWS tree hash signature relies on Thomas Baier's tool which we should be grateful for!

About

This program automates a nextcloud instance's backup with S3 Glacier upload. Daily archives are made with weekly, monthly and yearly rotations. The idea is to keep useful archives at significant times.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages