I think, I found it. It’s a failure in the nextcloud backup script.
My fault, when I made this file, I never checked, if it works and if backups were created. And I forgot about it, sorry.
@MichaIng could you please check the syntax of the attached script?
I made a mistake when copying from https://dietpi.com/forum/t/nextcloud-calender-contact-backup-script/5911/1
Result when executed manually:
No SQL dump is created.
And continuous error Loop:
./nextcloud_db_backup: 13: [[: not found rm: das Entfernen von '' ist nicht möglich: Datei oder Verzeichnis nicht gefunden
#!/bin/dash
# Enable maintenance mode
sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --on
# Backup Nextcloud database with numerically sortable timestamp
mysqldump nextcloud > /mnt/dietpi_userdata/backup/$(date +%Y-%m-%d_%T).sql
# Disable maintenance mode
sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --off
# Remove old backups until max 10 are left
until [[ $(find /mnt/dietpi_userdata/backup/ -name '*.sql' | wc -l) -le 10 ]]
do
rm -v "$(find /mnt/dietpi_userdata/backup/ -name '*.sql' | sort -n | head -1)"
done
exit 0
When I change path from /mnt/dietpi_userdata/backup/ to /mnt/128/backup/, the SQL dump is created.
Both backup folders are owned by root and have drwxr-xr-x.
can you share following
readlink /mnt/dietpi_userdata
readlink -f /mnt/dietpi_userdata
ls -la /mnt/dietpi_userdata/backup/
ls -la /mnt/128/backup/
lsblk -o name,fstype,label,size,ro,type,mountpoint,partuuid,uuid
readlink -f /mnt/dietpi_userdata
/mnt/dietpi_userdata
ls -la /mnt/dietpi_userdata/backup/
insgesamt 8
drwxr-xr-x 2 root root 4096 4. Mär 03:43 .
drwxrwxr-x 13 dietpi dietpi 4096 22. Feb 19:59 …
ls -la /mnt/128/backup/
insgesamt 204200
drwxr-xr-x 2 root root 4096 4. Mär 03:37 .
drwxrwxrwx 13 www-data www-data 4096 4. Mär 03:36 …
-rw-r–r-- 1 root root 209086023 4. Mär 03:37 2022-03-04_03:37:22.sql
lsblk -o name,fstype,label,size,ro,type,mountpoint,partuuid,uuid
NAME FSTYPE LABEL SIZE RO TYPE MOUNTPOINT PARTUUID UUID
sda 114,6G 0 disk
└─sda1
ext4 114,5G 0 part /mnt/128 dd3ad002-01 596a46a7-d2a1-4c7b-918f-3e64732233ac
sdb 233,3G 0 disk
└─sdb1
ext4 233,2G 0 part /mnt/256 aebece80-b588-49b3-8915-7560c330d847 20c4b904-1f5f-41f6-86a9-5aae128a3ab4
mmcblk0
│ 238,8G 0 disk
├─mmcblk0p1
│ vfat boot 256M 0 part /boot e8af6eb2-01 DC3E-E470
└─mmcblk0p2
ext4 rootfs
238G 0 part / e8af6eb2-02 a7adb26a-8b87-4729-99c8-9f5ac069d51e
There was a syntax error in the example script, i.e. it uses dash but contained [[ … ]] bash syntax. I adjusted it in the linked post. Basically replace double braces with single braces [ … ]. I also changed it from an “until” to a “while” loop, making an infinite loop less likely, e.g. breaking in case of an error.
I have no idea how changing the target directory should have solved the syntax error, did you change something else in the script?
@MichaIng: thanks for correcting the mistake in the script, i would never have found that.
I made an error while testing the path behaviour, i run mysqldumb nextcloud > /mnt/128/backup/filename.sql, the sql-file was created.
for the other path (/mnt/dietpi_userdata/backup/) i ran the backup script with mistake (see attached file). The sql files in the folder are deleted by the script just after creating. Therefore i thought i was depending on the path.
Thanks a lot for your patience, time and knowledge. I always made a backup of the sdcard, now i want to try to backup and restore! nextcloud using nextcloud script and backup and restore dietpi with dietpi script.
nextcloud_db_backup.falsch.txt (607 Bytes)