LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Backup regularly the /home? (https://www.linuxquestions.org/questions/linux-server-73/backup-regularly-the-home-912530/)

Xeratul 11-08-2011 01:27 PM

Backup regularly the /home?
 
Hello,

I have a very simple question, which is actually a pretty difficult one.

It has lot of dependencies ;) if you know what I mean ;)

For the moment, I use. I dont like it much because rsync could be deleting the deleted files of the real /home. However rsync could fail time to time, I have experienced.

Code:

0 0    * * 5  root    cd ; touch /forcefsck
0 0    * * 5  root    cd /root ; cp -r /home /mnt/backup


I would like to avoid RAID + to have a simple way.

Code:

> cp -r -u  /home /mnt/backup  # could work but unreliable
> the rsync way                # sometimes it can fail with persmissions (e.g. some weird cases), less reliable
> others ?

Any input would be helpful :)

Thank you !!!!!

jeewiz 11-08-2011 01:30 PM

I would tar it up and apply a date stamp...

Code:

DATE=`date +%...`
tar -czpf home_backup_$DATE.tgz /home


TobiSGD 11-08-2011 01:34 PM

Quote:

Originally Posted by Xeratul (Post 4519076)
For the moment, I use. I dont like it much because rsync could be deleting the deleted files of the real /home. However rsync could fail time to time, I have experienced.

rsync will only delete files if you specify one of the delete options. Never had problems with that.
Quote:

> the rsync way # sometimes it can fail with persmissions (e.g. some weird cases), less reliable
I see it only have problems when you copy files to a filesystem that doesn't support Unix file permissions, like FAT or NTFS.

Quote:

I would like to avoid RAID
RAID is in no way a backup solution, its intention is to keep downtimes short in case of hardware failure.

Quote:

> cp -r -u /home /mnt/backup # could work but unreliable
Why do you think that this is unreliable?

Quote:

> others ?
There are some programs for that (came up with that after a short websearch), but I prefer rsync and it never has failed for me.

jlinkels 11-08-2011 08:26 PM

Quote:

Originally Posted by TobiSGD (Post 4519084)
but I prefer rsync and it never has failed for me.

+1

Using USB hard disks for complete disk mirroring. A real no-brainer.
On critical machines I make a daily backup, but swap the USB disk with one off-site weekly.

jlinkels

d3vrandom 11-09-2011 12:35 AM

Use rsnapshot instead of just rsync. Rsnapshot is a collection of perl scripts that allows you to maintain incremental backups spanning multiple time periods using rsync. This way you can have daily, weekly, and monthly backups. It uses symbolic links extensively so disk space usage is minimized. I wrote a guide on how to use rsnapshot if you are interested.

jlinkels 11-10-2011 06:11 AM

I am not sure yet I want anything else but a verbatim copy of my data, but OTOH being able to roll back changes is valuable as well. Without using a tape rotation scheme. It has happened before that I overwrote my backup before I restored files from something stupid I did. I am going to look in it further. Thanks for posting.

jlinkels

d3vrandom 11-10-2011 11:09 PM

Just want to add that the if you use rsnapshot you won't have to worry about what happens if a backup fails. In such an event two things will happen:

- Cron will inform you that the backup failed
- The next time rsnapshot runs it will automatically roll over the failed backup. That is it will delete it and go back to the last successful backup.

So you won't loose backups just because the power went out or something like that.

d3vrandom 11-10-2011 11:12 PM

And BTW the snapshots rsnapshot makes are copies. You can copy them back to your home directory or anywhere else using cp:

Code:

cp -rp daily.0/home/user/* /home/user/

Xeratul 11-13-2011 04:09 AM

Quote:

Originally Posted by d3vrandom (Post 4521223)
And BTW the snapshots rsnapshot makes are copies. You can copy them back to your home directory or anywhere else using cp:

Code:

cp -rp daily.0/home/user/* /home/user/

cp -rd does delete the target if files are not existing anymore on the source?

rsync sometimes miss files, and does not like fat32, and sometimes is not so accurate

what would be the alternatives to rsync that would work better with --delete option like?

d3vrandom 11-14-2011 12:54 AM

Quote:

Originally Posted by Xeratul (Post 4522742)
cp -rd does delete the target if files are not existing anymore on the source?

rsync sometimes miss files, and does not like fat32, and sometimes is not so accurate

what would be the alternatives to rsync that would work better with --delete option like?

I wrote cp -rp not rd. And that is for restoring from the backup. Anyway because you have multiple incremental backups the --delete option is not a problem. For example say you have rsync running and you have it setup as follows:

7 daily backups - daily.0- daily.6
4 weekly backups - weekly.0 - weekly.3
3 monthly backups - monthly.0 - monthly.2

So you now have backups that go back 3 months. If you delete a file and a backup is made only your latest backup is spoiled i.e. daily.0. You can still recover the file from backups daily.1-6 and any of the weekly or monthly backups.

Anyway if you don't like rsync you can always use tar or some other method. It's entirely your choice.

lithos 11-14-2011 06:32 AM

I could give you some reading for backup with TAR here
if you want this solution


All times are GMT -5. The time now is 11:07 AM.