Sign inSign up

jumpaku/backup-with-nextcloud

By jumpaku

•Updated about 6 years ago

Docker image to backup files with remote nextcloud.

Image
0

256

jumpaku/backup-with-nextcloud repository overview

⁠backup-with-nextcloud

Docker image to backup files with remote nextcloud.

⁠Introduction

  • It synchronizes the files to be backed up with your nextcloud server.
  • It can prepare the files to be backed up by executing the specified script.
  • It repeats these processes with cron.

⁠Volumes

⁠/backup/

This container synchronizes files in a directory named /backup/ with a remote nextcloud. Mount the host directory containing the files to be backed up to /backup/ of this container.

⁠/backup.sh

This container can execute a complex process to prepare the files to be backed up. If you want to execute the complex process, create a script that places the files to be backed up to /backup/ and mount the script as backup.sh to /.

If backup.sh is not mounted, the following script is generated by default.

#!/bin/bash

⁠Environments

environmentdefaultrequireddescription
CRON_EXP0 * * * *nocron expression
CRON_USERrootnouser who execute cron command
NC_URLyesURL of Nextcloud's folder
NC_USERyesuser of Nextcloud
NC_PASSWORDyespassword for the user of nextcloud

From the following environments:

    environment: 
      - "CRON_EXP=0  *  *  *  *"
      - "CRON_USER=root"
      - "NC_URL=http://nextcloud/remote.php/webdav/"
      - "NC_USER=nc_user"
      - "NC_PASSWORD=nc_password"

the following /etc/crontab is generated.

0  *  *  *  * root /backup.sh && nextcloudcmd --user nc_user --password nc_password /backup/ http://nextcloud/remote.php/webdav/

⁠Examples for docker-compose

Execute docker-compose up -d with the following docker-compose.yml.

  • docker-compose.yml
version: '3'

services: 
  backup:
    image: 'jumpaku/backup-with-nextcloud'
    environment: 
      - 'NC_URL=http://nextcloud.example.com/remote.php/webdav/'
      - 'NC_USER=nc_user'
      - 'NC_PASSWORD=nc_password'
    volumes: 
      - './backup/:/backup/'

Or execute docker-compose up -d with the following docker-compose.yml and backup.sh.

  • docker-compose.yml
version: '3'

services: 
  backup:
    image: 'jumpaku/backup-with-nextcloud'
    environment: 
      - 'NC_URL=http://nextcloud.example.com/remote.php/webdav/'
      - 'NC_USER=nc_user'
      - 'NC_PASSWORD=nc_password'
    volumes: 
      - './backup.sh:/backup.sh:ro'
      - './backup-from/:/backup-from/'
  • backup.sh
#!/bin/bash
cp -Rf /backup-from/* /backup/

⁠Test

Execute docker-compose -f ./test/docker-compose.yml up --build -d, wait for a while, and check as follows:

 docker-compose -f ./test/docker-compose.yml exec backup cat /backup/date.txt
# => Tue Sep 3 03:59:01 UTC 2019
 docker-compose -f ./test/docker-compose.yml exec nextcloud cat ./data/admin/files/date.txt
# => Tue Sep 3 03:59:01 UTC 2019

Tag summary

Content type

Image

Digest

Size

143.3 MB

Last updated

about 6 years ago

docker pull jumpaku/backup-with-nextcloud