Koozali.org: home of the SME Server

Delete Before rsync

Offline smnirosh

  • *****
  • 329
  • +0/-0
  • Learning never ends
Delete Before rsync
« on: June 27, 2016, 11:35:28 AM »
I used rsync for full backup. In a 500GB hard disk there are 75GB free space. But everytime the rsync is stop responding with lefting behind 0GB space of HDD.
I am willing to use following command to delete destination folder before rsync begins. is it a good idea?

rm -rf /destination/* && rsync -avr /source /destination


Offline Daniel B.

  • *
  • 1,700
  • +0/-0
    • Firewall Services, la sécurité des réseaux
Re: Delete Before rsync
« Reply #1 on: June 27, 2016, 12:03:24 PM »
No, it'd defeat the purpose of rsync, which is to sync only modified files. You could try with the --delete-before option
C'est la fin du monde !!! :lol:

Offline smnirosh

  • *****
  • 329
  • +0/-0
  • Learning never ends
Re: Delete Before rsync
« Reply #2 on: June 27, 2016, 12:15:08 PM »
yes i tried that option. But it deletes only modified files. According to me it's not a full backup.
am i correct?

Offline Daniel B.

  • *
  • 1,700
  • +0/-0
    • Firewall Services, la sécurité des réseaux
Re: Delete Before rsync
« Reply #3 on: June 27, 2016, 12:17:39 PM »
No. It deletes files which are on the destination (the backup drive) but no more on the source. Note that this is what --delete does no matter what. You can then choose to delete before the transfert (--delete-before), during the transfert (--delete-during) or after the transfert is finished (--delete-after)
C'est la fin du monde !!! :lol:

Offline smnirosh

  • *****
  • 329
  • +0/-0
  • Learning never ends
Re: Delete Before rsync
« Reply #4 on: June 27, 2016, 12:31:37 PM »
you mean --delete-before will deletes all the files in destination no matter edited or not, before rsync take place?

Offline Daniel B.

  • *
  • 1,700
  • +0/-0
    • Firewall Services, la sécurité des réseaux
Re: Delete Before rsync
« Reply #5 on: June 27, 2016, 02:57:39 PM »
No. It'll delete the files which are on the destination, but not on the source anymore. And it'll do so before updating the files which exist on both side but have been edited on the source after the previous sync.
C'est la fin du monde !!! :lol:

Offline Jean-Philippe Pialasse

  • *
  • 2,912
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Delete Before rsync
« Reply #6 on: June 27, 2016, 03:37:40 PM »
full backup means you get an up to date copy of all the files on the backup.

incremental backup means you get only modified and new files.

Usually this concept is attached with the creation of an archive file  containing the files you want to backup.


Rsync uses an incremental algorithm to maintain a full backup. ( Yes I know it could mix you having the two magical words in one sentence). Instead of copying all the file to the backup place, it compares the original files with the backup version and according to the provided  options will transfer transfer only modified and new files , and delete deleted files to synchronize the backup with source.

So as told Daniel, there is no more use of rsync if you start with a rm.

The idea is to save the time of copy and tranfer from one place to another to maintain a full version backup, when you already have part of the file at the destination site.

Offline smnirosh

  • *****
  • 329
  • +0/-0
  • Learning never ends
Re: Delete Before rsync
« Reply #7 on: June 27, 2016, 06:16:05 PM »
Ok. Thanks to your explanation now i understood the use of "--delete-before." As I explained above I want to do a full backup but the nas drive has 160GB free out of 1000GB and server has 75 Gb out of 500 gb The nas drive is mount to server when rsync runs. The problem is when the rsync run in full backup mode, the free space the server has is going to 0GB and stuck everything. That's why I asked you to give me a option to delete the dest. Backup before run rsync. You suggest me to run everytime the incrimental mode?

Offline Daniel B.

  • *
  • 1,700
  • +0/-0
    • Firewall Services, la sécurité des réseaux
Re: Delete Before rsync
« Reply #8 on: June 27, 2016, 06:23:19 PM »
I don't understand what you mean. Rsync has no such "full" or "incremential" mode. It's a tool which synchronizes one source directory with one destination directory. If the destination is empty, it'll copy everything. If the destination already has data, it'll only copy the differences. But this is just a implementation detail to speed up the transfer. In the end, the destination will be a full copy of the source.
C'est la fin du monde !!! :lol:

Offline Jean-Philippe Pialasse

  • *
  • 2,912
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Delete Before rsync
« Reply #9 on: June 27, 2016, 06:36:12 PM »
Ok. Thanks to your explanation now i understood the use of "--delete-before." As I explained above I want to do a full backup but the nas drive has 160GB free out of 1000GB


and server has 75 Gb out of 500 gb

meaning you want to backup 425GB ?

The nas drive is mount to server when rsync runs.

have you excluded the mount point of your NAS on the SME from your rsync command ? Otherwise rsync will copy NAS data again on the NAS....

meaning if your mount point is  /mnt/NAS
you need to add --exclude=/mnt/NAS to rsync.

The problem is when the rsync run in full backup mode, the free space the server has is going to 0GB and stuck everything.
(as told Daniel, there is no mode for rsync, it always intend to do a full backup, this is just its way of doing it that is special)

if by server you mean the SME, then  you are not syncing on your NAS but on your SME ,
- either because your NAS is not really mounted and you are backuping on the folder created to mount your NAS,
- either your pointing the wrong path to backup
- either you have mixed destination and source

That's why I asked you to give me a option to delete the dest. Backup before run rsync. You suggest me to run everytime the incrimental mode?

I suggest you paste there the command you try to do to clarify the situation ....

Offline smnirosh

  • *****
  • 329
  • +0/-0
  • Learning never ends
Re: Delete Before rsync
« Reply #10 on: June 27, 2016, 08:10:20 PM »
Normally i used to use this command until i copied of 75 GB of data to the server. After that transfer i got this error. The error code is rsync 11. I use rsync -avr /home /mnt/nasbackup.  As daniel said there is no incremental or full, i think i got an idea. Thanks