# DietPi-Sync doesn't delete files on destination folder

**URL:** https://dietpi.com/forum/t/dietpi-sync-doesnt-delete-files-on-destination-folder/4583
**Category:** Troubleshooting
**Created:** [30 October 2020 20:28 UTC](https://dietpi.com/forum/t/dietpi-sync-doesnt-delete-files-on-destination-folder/4583 "2020-10-30T20:28:54Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![mafioso12dk](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/m/858c86/32.png) [@mafioso12dk](https://dietpi.com/forum/u/mafioso12dk)
#### Post date: [30 October 2020 20:28 UTC](https://dietpi.com/forum/t/dietpi-sync-doesnt-delete-files-on-destination-folder/4583/1 "2020-10-30T20:28:54Z")

</div>

Hi. I have 2 HDDs connected to Raspberry Pi 4b through USB ports. Disk 1 is mounted in /mnt/share, Disk 2 is mounted in /mnt/backup. Everything works just fine, disks mount automatically even after reboot and after cold start, but i have problem with dietpi-sync function. I want to have exact copy of share disk on backup disk so I set Delete Mode and Daily Sync to ON. I created for tests New Folder in /mnt/backup location and tried to run rsync and the tool didn’t delete this folder. I was trying multiple times and everytime effect was the same.

Then I ran this command in terminal:  
sudo rsync -hvrPt --delete /mnt/share/ /mnt/backup

and everything synced just fine  
Anyone knows what’s the matter

Thanks in advance

---

<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: [1 November 2020 20:14 UTC](https://dietpi.com/forum/t/dietpi-sync-doesnt-delete-files-on-destination-folder/4583/2 "2020-11-01T20:14:16Z")

</div>

Many thanks for your report. Indeed there is a bug, introduced with v6.33. I just fixed it: [https://github.com/MichaIng/DietPi/commit/e5ed1dbc4f65c2b3aff2508bd1291cf5dedfe04e#diff-5af048f2cc1f2f943579889d33d8636a0e0cb490245a76709721ca1ed8747a9fL139-R139](https://github.com/MichaIng/DietPi/commit/e5ed1dbc4f65c2b3aff2508bd1291cf5dedfe04e#diff-5af048f2cc1f2f943579889d33d8636a0e0cb490245a76709721ca1ed8747a9fL139-R139)  
Manually adjust that one highlighted line. “rsync\_option” variable is not used anymore and we forgot to adjust this one case where it is used. I wonder that our code quality scan didn’t throw an error, as actually it does when a variable is assigned that is never used 🤔.

Changelog: [https://github.com/MichaIng/DietPi/commit/ad07a309e4301c7038ec1da1e26d23f5d854fb89](https://github.com/MichaIng/DietPi/commit/ad07a309e4301c7038ec1da1e26d23f5d854fb89)

---

<div class="post-metadata">

### Author: ![mafioso12dk](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/m/858c86/32.png) [@mafioso12dk](https://dietpi.com/forum/u/mafioso12dk)
#### Post date: [4 November 2020 12:00 UTC](https://dietpi.com/forum/t/dietpi-sync-doesnt-delete-files-on-destination-folder/4583/3 "2020-11-04T12:00:16Z")

</div>

Thanks for help, now “delete” option works but I think it deletes to much now. It started to delete \*.db and \*.tmp files although they exist on the source disk. Maybe it doesn’t see hidden files on source disk?

---

<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: [5 November 2020 18:25 UTC](https://dietpi.com/forum/t/dietpi-sync-doesnt-delete-files-on-destination-folder/4583/4 "2020-11-05T18:25:55Z")

</div>

rsync includes hidden files and directories within the source directory. Please recheck if you added excludes (/boot/dietpi/.dietpi-sync\_inc\_exc), since those are removed from the target as well. The script does a dry run first and allows you to review the log file, so you could review this and assure that really existing and non-excluded files are removed.

---

<div class="post-metadata">

### Author: ![mafioso12dk](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/m/858c86/32.png) [@mafioso12dk](https://dietpi.com/forum/u/mafioso12dk)
#### Post date: [9 November 2020 15:02 UTC](https://dietpi.com/forum/t/dietpi-sync-doesnt-delete-files-on-destination-folder/4583/5 "2020-11-09T15:02:23Z")

</div>

I don’t have any excludes defined in the file. After running the command I wrote above:

```nohighlight
sudo rsync -hvrPt --delete /mnt/share/ /mnt/backup

```

the Used amount of space is exactly the same on both disk, but after using dietpi-sync the Used amount of space on the backup disk is lower and it deletes files that certainly are on the share disk.

It happend after the 6.33 update. Before everything was fine

---

<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: [10 November 2020 00:00 UTC](https://dietpi.com/forum/t/dietpi-sync-doesnt-delete-files-on-destination-folder/4583/6 "2020-11-10T00:00:19Z")

</div>

Hmm, we use and used: -aHP4 --info=name0 --info=progress2 --delete --delete-excluded  
I see we have a default exclude list (we did before, this has not changed): [https://github.com/MichaIng/DietPi/blob/master/dietpi/dietpi-sync#L57-L65](https://github.com/MichaIng/DietPi/blob/master/dietpi/dietpi-sync#L57-L65)  
This explains the .tmp files and you said .db files? At least the old-style (decentralised) Windows image thumbs.db files are excluded as well. Does this explain all your missing files? Else please list examples that you did not expect, so I can test this as well.

---

<div class="post-metadata">

### Author: ![mafioso12dk](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/m/858c86/32.png) [@mafioso12dk](https://dietpi.com/forum/u/mafioso12dk)
#### Post date: [12 November 2020 08:21 UTC](https://dietpi.com/forum/t/dietpi-sync-doesnt-delete-files-on-destination-folder/4583/7 "2020-11-12T08:21:46Z")

</div>

So when this files are excluded by default so everything seems to work fine. I just didn’t know about it and thought that every single file should be copied. Thank you very much for your help

---

<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: [12 November 2020 19:46 UTC](https://dietpi.com/forum/t/dietpi-sync-doesnt-delete-files-on-destination-folder/4583/8 "2020-11-12T19:46:20Z")

</div>

Probably we should make this transparent, i.e. creating a default exclusion file but allowing to view and edit it.
