The target is to setup 3-2-1 backup rule for my nextcloud instance at a minimum. if you are not familiar with this general backup guideline I suggest you read more on it before you proceed.
- 3 copies of production data
- 2 media types
- Elastic File System (non-versioned)
- Object Storage (versioned)
- 1 offline copy (versioned) - setting up the offline copy isnt covered in this page
There are following options to choose from when deciding how to use the object storage as the versioned backup solution:
- Setup object storage as filesystem (s3fs)
- (pro) get a point in time copy of data that isn't cloud provider dependent
- (pro) allows the backup shell script to take care of object rotation.
- (con) unnecessarily expose all backup data in the filesystem.
- (con) makes it harder to use the object storage from the context of another client application
- Use s3cmd for uploading the backup
- (pro) can use the S3cmd sync for storage/filesystem backup
- (con) need to manage lifecycle/versions of data outside the backup script
- Use cloud provider native snapshots
- (pro) use provider specific APIs to take snapshots of compute and block storage
- (pro) easiest/fastest recovery option
- (con) snapshots arent useful outside the cloud provider
I prefer option2 as of now, and given theres flexibility to change the backup design as the service scales I don't see the need to over-engineer it as of now. In near future I will have both option2 and option3 running in parallel.
Heres the steps I followed:
- Setup the DigitalOcean Space and get a managed key
- Install and Configure S3cmd
- https://www.digitalocean.com/docs/spaces/resources/s3cmd/
- sudo apt-get update
- sudo apt-cache madison s3cmd (make sure the version is above 2)
- sudo apt-get install s3cmd -y
- sudo s3cmd --configure (go through the interactive process)
- Create Backup folder
- sudo mkdir -p /media/nextcloud_data/backups
- sudo mkdir -p /media/nextcloud_data/backups/logs
- sudo mkdir -p /media/nextcloud_data/backups/tmp
- Create backup script
- sudo vim /usr/sbin/nextcloudbackup.sh
- Todo: get script from github
- sudo chmod +x /usr/sbin/nextcloudbackup.sh
- sudo /usr/sbin/nextcloudbackup.sh
- Cron setup
- sudo visudo
- opuser ALL=(ALL) NOPASSWD: /usr/sbin/nextcloudbackup.sh
- sudo crontab -u <username> -e
- 0 2 * * * sudo /usr/sbin/nextcloudbackup.sh
- Backup pod and volume
Reading material:
No comments:
Post a Comment