Skip to main content

7.) Backup

Nextcloud Backup

- I use the backup from the nexcloudpi panel (https://ip-to-your-pi:4443) to make a full backup of my nextcloud, because it is so        easy and it is even more easy when it must be restored.


- Destination Directory : a valid path on your pi for your backup files

- Include data : if deactivated only your nextcloud configuration will be backup but not your files on you nextcloud

- Backup periodicity (in days) : days between the backups from now on

- Number of backups to keep : how many full backups you want to keep; check for enough free disc space



Docker Backup


- for my docker stuff i use a little backup script

- look where you want to store your backup files in; this will be the path for "backupdir" in the script 

- make a directory for the backup script

mkdir backup

- cd backup


- copy this in

#here are the variables you have to adjust----
dockerdata=/media/dockerdata                  #the folder where all my dockerfiles are stored in
backupdir=/media/backup                       #place where the backups are stored in
pi=/home/pi/                                  #home of pi , all my folder with the docker-compose.yml files are in here

#create backup folder structure if not already done
date && mkdir $backupdir/dockerdata
date && mkdir $backupdir/home
date && mkdir $backupdir/home/pi

date && echo backing up Bitwaden-database...
date && sudo rsync --progress -h -a --delete $bitwarden $backupdir/bw-data
date && echo backing up Dockerdata...
date && sudo rsync -avSAXH --delete $dockerdata $backupdir
date && echo backing up home directory...
date && sudo rsync -avSAXH --delete $pi $backupdir/home/pi
date && echo backup complete


- save and exit (STRG+O ; STRG+X)

- make it executable 

sudo chmod +x


- now you can ran this scrip via a cron job daily at nigth (maybe 2:30) 

- type in :

sudo crontab -e 

- copy this line at the end

30 2 * * * /home/pi/backup/ >> /var/log/backup.log 2>&1


- save and exit (STRG+O ; STRG+X)


now eyer night at 2:30 the script which is in the folder /home/pi/backup will be executed and a log file will be written at /var/log/backup.log. There you can see if everything works fine. To open this log file, connect to your and type in :

nano /var/log/backup.log