# No space left on device

**URL:** https://dietpi.com/forum/t/no-space-left-on-device/6175
**Category:** Troubleshooting
**Created:** [11 January 2022 21:57 UTC](https://dietpi.com/forum/t/no-space-left-on-device/6175 "2022-01-11T21:57:03Z")
**Posts on this page:** 6
**Page:** 4

<div class="post-metadata">

### Author: ![droogi](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/d/b782af/32.png) [@droogi](https://dietpi.com/forum/u/droogi)
#### Post date: [4 March 2022 02:15 UTC](https://dietpi.com/forum/t/no-space-left-on-device/6175/61 "2022-03-04T02:15:24Z")

</div>

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](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:

```nohighlight
./nextcloud_db_backup: 13: [[: not found rm: das Entfernen von '' ist nicht möglich: Datei oder Verzeichnis nicht gefunden

```

```nohighlight
#!/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

```

---

<div class="post-metadata">

### Author: ![droogi](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/d/b782af/32.png) [@droogi](https://dietpi.com/forum/u/droogi)
#### Post date: [4 March 2022 02:47 UTC](https://dietpi.com/forum/t/no-space-left-on-device/6175/62 "2022-03-04T02:47:46Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)
#### Post date: [4 March 2022 16:38 UTC](https://dietpi.com/forum/t/no-space-left-on-device/6175/63 "2022-03-04T16:38:05Z")

</div>

can you share following

```nohighlight
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

```

---

<div class="post-metadata">

### Author: ![droogi](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/d/b782af/32.png) [@droogi](https://dietpi.com/forum/u/droogi)
#### Post date: [4 March 2022 22:59 UTC](https://dietpi.com/forum/t/no-space-left-on-device/6175/64 "2022-03-04T22:59:06Z")

</div>

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

---

<div class="post-metadata">

### Author: ![MichaIng](https://dietpi.com/forum/user_avatar/dietpi.com/michaing/32/7_2.png) [@MichaIng](https://dietpi.com/forum/u/MichaIng)
#### Post date: [6 March 2022 15:34 UTC](https://dietpi.com/forum/t/no-space-left-on-device/6175/65 "2022-03-06T15:34:38Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![droogi](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/d/b782af/32.png) [@droogi](https://dietpi.com/forum/u/droogi)
#### Post date: [6 March 2022 20:15 UTC](https://dietpi.com/forum/t/no-space-left-on-device/6175/66 "2022-03-06T20:15:45Z")

</div>

@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](https://dietpi.com/forum/uploads/short-url/87Cymd0q3UaB0fMC3TGZmHdzpgP.txt) (607 Bytes)

[Previous page](https://dietpi.com/forum/t/no-space-left-on-device/6175.md?page=3)
