Code Monkey home page Code Monkey logo

nextcloud-backup.sh's Introduction

nextcloud-backup.sh

A shell script to backup nextcloud according to the official documentation.

The script switches on maintenance mode, rsyncs the nextcloud and data folder and dumps the mysql database. On exit maintenance mode is disabled again.

Features

  • Toggles maintenance mode
  • Extracts data folder location and database parameters from the nextcloud config

Requirements

  • php
  • rsync
  • sudo
  • mysqldump

The script assumes that it can run sudo as the owner of the nextcloud occ script (i.e. www-data)

Usage

nextcloud-backup.sh [/path/to/nextcloud] [/path/to/backup] [backup suffix]

Defaults for source and destination are /var/www/nextcloud and /mnt/backups/nextcloud The default suffix for backup folders and the SQL dump is _$(date + %Y%m%d)

Example

nextcloud-backup.sh /var/www/nextcloud /mnt/backups/nextcloud

Caveats

The default rsync settings are suitable for backup onto a CIFS share which cannot preserve owner/group. to override pass something like RSYNC_ARGS="-avx --delete" in the environment.

Environment variables

  • RSYNC_ARGS: arguments passed to rsync (default: -avx --no-owner --no-group --delete)
  • SUFFIX: the backup folder and SQL dump suffix (default: _$(date +"%Y%m%d"))
  • DRYRUN: prefixed to all commands which do work, i.e. rsync/php/sudo, set to echo for a dryrun (default is empty)
  • PREPARE: Run before mysqldump + rsyn is run (default is empty)
  • TEARDOWN: Run after mysqldump and rsync (default is empty)

nextcloud-backup.sh's People

Contributors

asmw avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.