"zfs receive -F" not destroying snapshots that do not exist on the sending side

Hi guys,

On one of our backup machines I noticed the number of snapshots growing and growing. When checking the backup script I noticed that the [cmd=""]zfs receive[/cmd] command was using the "-F" flag, which should normally (quote from the man page) "destroy snapshots and file systems that do not exist on the sending side".

I also tried it manually and for some reason, it does not work. The machines in question are 9-STABLE (r236943 and r236355) amd64.

The cmd's I used for manual checking were:
[cmd=""]zfs create rpool/test[/cmd]
[cmd=""]zfs snapshot rpool/test@snap1[/cmd]
[cmd=""]zfs snapshot rpool/test@snap2[/cmd]
[cmd=""]zfs snapshot rpool/test@snap3[/cmd]
[cmd=""]zfs snapshot rpool/test@snap4[/cmd]
[cmd=""]zfs send rpool/test@snap1 | ssh -c arcfour ssh backup.local zfs receive -F backup/test[/cmd]
[cmd=""]zfs send -i snap1 rpool/test@snap2 | ssh -c arcfour ssh backup.local zfs receive -F backup/test[/cmd]
[cmd=""]zfs send -i snap2 rpool/test@snap3 | ssh -c arcfour ssh backup.local zfs receive -F backup/test[/cmd]
[cmd=""]zfs destroy rpool/test@snap1[/cmd]
[cmd=""]zfs send -i snap3 rpool/test@snap4 | ssh -c arcfour ssh backup.local zfs receive -F backup/test[/cmd]


At this point snap2, snap3 and snap4 should be present on the backup machine and snap1 shuold be gone. Unfortunately, snap1 does not get deleted.

What am I missing?
 
da1 said:
When checking the backup script I noticed that the [cmd=""]zfs receive[/cmd] command was using the "-F" flag, which should normally (quote from the man page) "destroy snapshots and file systems that do not exist on the sending side".
It says something complete different in my man pages.

Code:
      -F

               Force a rollback of the file system to the most recent snapshot
               before performing the receive operation. If receiving an incre-
               mental  replication  stream  (for example, one generated by zfs
               send -R -[iI]), destroy snapshots and file systems that do  not
               exist on the sending side.

A little further up is:
Code:
           When  a  snapshot  replication  package stream that is generated by
           using the zfs send -R command is  received, any snapshots  that  do
           not  exist  on  the sending location are destroyed by using the zfs
           destroy -d command.
 
Read the last 2 lines of the first code block SirDice. Second, I did not use the -R flag :).
 
Read the first part of the line ;)

If receiving an incremental replication stream (for example, one generated by zfs send -R -[iI]), destroy snapshots and file systems that do not exist on the sending side.

As far as I understood it it only works if you use zfs send -R.
 
I understand it differently but at this point, it makes no difference since I tried sending the initial snapshot with the -R flag and all the rest with the -i flag and the results were the same; all 4 snapshots were kept.
 
da1 said:
I understand it differently but at this point, it makes no difference since I tried sending the initial snapshot with the -R flag and all the rest with the -i flag and the results were the same; all 4 snapshots were kept.

You need to send with the -R flag and receive with the -F flag your incremental snapshots also.
 
Hmm, this causes a problem if one needs to send only 1 dataset and not any children that dataset may have.
 
da1 said:
Hmm, this causes a problem if one needs to send only 1 dataset and not any children that dataset may have.

Yes, but it can not work any other way. Since the -F flag forces a rollback, the children datasets must also exist.
 
Back
Top