# Making incremental backup with Rsync



## adripillo (May 21, 2013)

I have a disk UFS mounted on /media/datos and I have a folder on my main HDD where I want to save the incremental back up, /usr/home/USER/bkup.

`rsync -avz /media/datos /usr/home/USER/bkup`

It says that with the -z option it will compress but it does not compress and it just cop*ies* all from one location to another. Also *i*t says that rsync makes incremental backups by default, but.

Does anyone know which options I need to use to copy all from the origin to one single compressed file? Thanks again.


----------



## freesbies (May 21, 2013)

Try this:

`# dd if=/media/datos | gzip > /usr/home/USER/bkup/image.gz`


----------



## adripillo (May 21, 2013)

freesbies said:
			
		

> Try this:
> 
> `# dd if=/media/datos | gzip > /usr/home/USER/bkup/image.gz`



It just made a file image.gz but nothing inside.


----------



## freesbies (May 21, 2013)

*S*orry:

`# dd if=/media/datos of=/usr/home/USER/bkup/image | gzip -9 /usr/home/USER/bkup/image`


----------



## adripillo (May 21, 2013)

freesbies said:
			
		

> *S*orry:
> 
> `# dd if=/media/datos of=/usr/home/USER/bkup/image | gzip -9 /usr/home/USER/bkup/image`





```
gzip: can't stat: /usr/home/USER/bkup/image: 1+0 records in
1+0 records out
512 bytes transferred in 0.000041 secs (12485370 bytes/sec)
No such file or directory
```


----------



## freesbies (May 21, 2013)

What's your output when you do this: `# dd if=/media/datos of=/usr/home/USER/bkup/image`

And what's your hard disk drive path?


----------



## adripillo (May 21, 2013)

freesbies said:
			
		

> What's your output when you do this:
> `# dd if=/media/datos of=/usr/home/USER/bkup/image`
> 
> And what's your hard disk drive path?




```
# dd if=/media/datos of=/usr/home/USER/bkup/image
1+0 records in
1+0 records out
512 bytes transferred in 0.015518 secs (32994 bytes/sec)
```

I do not understand what you mean with the "hard disk drive path".


----------



## wblock@ (May 21, 2013)

Please do not use dd(1) as a backup tool.  It is terrible at that.  See Backup Options For FreeBSD.

rsync(1)'s -z option means it will compress the data before sending it to another system, and it will be decompressed on arrival.  It is for reducing network transfer time, not compressing a backup.


----------



## adripillo (May 21, 2013)

wblock@ said:
			
		

> Please do not use dd(1) as a backup tool.  It is terrible at that.  See Backup Options For FreeBSD.
> 
> rsync(1)'s -z option means it will compress the data before sending it to another system, and it will be decompressed on arrival.  It is for reducing network transfer time, not compressing a backup.



Yes I read that in your guide, I mean about dd but this is getting me a little crazy. I am still trying with different options, rsync makes an awesome backup, my problem is that it is not compressed and it re-makes it each time. I need that each time save that backups in a different file, like bk1.gz, bk2.gz (or .whatever).


----------



## DutchDaemon (May 21, 2013)

Just install and configure sysutils/rsnapshot and be done with it.


----------



## adripillo (May 21, 2013)

DutchDaemon said:
			
		

> Just install and configure sysutils/rsnapshot and be done with it.



Seems it works fine, will test it all the next month and I let you know. Thanks


----------



## wblock@ (May 21, 2013)

But sysutils/rsnapshot does not compress backups either.  Or rather, not by default.  It does save space by using hard links.


----------



## mix_room (May 22, 2013)

You could trying using geom_uzip to make a compressed disk-image, then direct rsnapshot to write the the mountpoint of this image.


----------



## adripillo (May 22, 2013)

wblock@ said:
			
		

> But sysutils/rsnapshot does not compress backups either.  Or rather, not by default.  It does save space by using hard links.



I am making now a test. Want to see what it does really.


----------



## adripillo (May 22, 2013)

It made a folder with Name.0 so *i*f next week makes another one Name.1 it could work for what I need. Thanks


----------



## atmosx (May 23, 2013)

I use rdiff-backup and I'm really happy with it. If you need encryption there's Duplicity (Google them).


----------



## phoenix (May 25, 2013)

ZFS with compression enabled and daily snapshots, is pretty much perfect for "incremental" backups via rsync. Create a ZFS filesystem, enable compression, use rsync to transfer the initial data over. Then create a snapshot. Next day, rsync the same data overtop the ZFS filesystem. rsync will only copy over changes to the files (this the incremental part). Create new snapshot. Repeat the rsync +snapshot each day.

Voila! Incremental snapshots, and all your files are accessible at all times in the snapshots.


----------



## adripillo (Jun 6, 2013)

Well, after testing it for several days I found that it does not make another folder. It just made a folder called Weekly.0 and then each time it runs it overwrites the same folder. I need that each week makes different folders.


----------



## adripillo (Jun 6, 2013)

Can I use the command cp or another copy command to copy a file to a folder but with the option to not replace. I mean I have bk.tgz, can cp or other command copy the file and auto set to rename it in case if the file exist?. Like bk.tgz bk2.tgz and so on.


----------



## adripillo (Jun 7, 2013)

I opened a new threa*d* since I need help to copy a file now. Thanks*.*


----------

