Question : How do I backup/snapshot a drive using proper parameters with rsync?

Greetings, experts.  Hopefully this is extremely simple for someone.  I have a server with an external drive mounted to it--and the purpose of this additional external drive is to backup the server.  I am trying to use rsync to take a "snapshot" of the drive that, in an emergency, I could restore from.

I am using the following:

rsync -avz --update

The problem I'm running into is my backup drive is now full--because the rsync I'm using isn't getting rid of files that no longer exist.  I know this because my backup drive should have twice as much capacity as the amount of data I'm trying to backup...and yet I'm out of space.

As an example of what I'm trying to do: if x.htm was on the server at one point and isn't any longer, then I don't need x.htm on the drive anymore.  The way I'm setup I don't have the need to, say, restore to a backup from three months ago or the like.

Is it possible to run an rsync command that will, just as it copies over changed files, also delete files that no longer exist on the drive?  Or am I looking at the wrong command for this function?

Thank you in advance for your wisdom.

Answer : How do I backup/snapshot a drive using proper parameters with rsync?

Hi,

that's the "--delete" option.

Quoting the manpage ( http://www.samba.org/ftp/rsync/rsync.html )

--delete This tells rsync to delete extraneous files from the receiving side (ones that aren't on the sending side), but only for the directories that are being synchronized. You must have asked rsync to send the whole directory (e.g. "dir" or "dir/") without using a wildcard for the directory's contents (e.g. "dir/*") since the wildcard is expanded by the shell and rsync thus gets a request to transfer individual files, not the files' parent directory.  

wmp

Random Solutions  
 
programming4us programming4us