Skip to main content

7.) 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.

NCPBackup.PNG

- 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

 

 

- for my docker stuff i use a little backup script

- mkdir backup

- cd backup

- nano backup.sh

- copy this in

 

#!/bin/bash
#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 placed in
pi=/home/pi/                                                      #home of pi , all my folder with the docker-compose.yml files are in here
#---------------------------------------

date                                                                     #writes the actual date and time for your log file

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

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

 

- save and exit

- make it executable 

- sudo chmod +x backup.sh

 

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

- connect to your pi

- type in : sudo crontab -e 

- copy this line at the end

 

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

 

- save and exit

now eyer night at 2:30 the script backup.sh 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 fin. To open this log file, connect to your and type in :

nano /var/log/backup.log