[SOLVED] What is the quickest and safest way to backup my root & home partitions?
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Should it be an 'image' backup or simply a 'file' backup?
What would be the best way to do this: rsync, dd, something else?
For example, if I trash my installation, (i.e. do something that I can't figure out how to reverse) I'd like to be able to re-format /dev/sda1 to ext4 and then restore my 'most recent set of unscrewed up by rob' files.
I have never created a cron job, and worse, I have never created a .sh file which, I think, is what I need to do.
Any input on this lofty plan would be appreciated.
Last edited by Robert.Thompson; 07-28-2011 at 09:44 AM.
Reason: typo
Click here to see the post LQ members have rated as the most helpful post in this thread.
If you want to automate with cron, then the external USB drive needs to be connected when the cron job executes.
Quote:
Should it be an 'image' backup or simply a 'file' backup?
There are many ways to perform a backup. I suspect you will receive many answers. I prefer files rather than images.
Quote:
What would be the best way to do this: rsync, dd, something else?
I have been using rsnapshot for a few years. I use a layered backup approach. I have two hard drives installed. Every three hours I run rsnapshot through cron and I backup all important user files and system configuration files. Because the hard drive is inside the case, this layer of backup is to protect my system from me. If the case is stolen or damaged those backups will not help me, but I have used those backup many times to recover from "fat thumb syndrome."
Every week I perform a manual backup of the entire system. I again use rsnapshot but I use a shell script to start the process. I use a different rsnapshot configuration file. I store that hard drive in a small fire-proof safe.
I have several additional computers here. They are not primary systems. Those systems are static. If they are powered on when my backups are run every three hours, system configuration files get updated to my primary system. I use rsnapshot to backup those systems and a different rsnapshot config file.
Every month I send myself an email to perform a manual backup of those systems. Basically I power on the "remote" systems and run my shell script. Because rsnapshot uses rsync and hard links, and those systems are static, the backups take less than 15 minutes total.
I like rsnapshot because of the way rsync and hard links are used. I have more than six months of backups on a single 750 GB hard drive, which includes backups of all systems here. Without rsnapshot I'd be able to hold only about two backups on the disk.
I have used the backups to recover files or compare previous versions of scripts, etc. Worked great every time.
Should it be an 'image' backup or simply a 'file' backup?
What would be the best way to do this: rsync, dd, something else?
For example, if I trash my installation, (i.e. do something that I can't figure out how to reverse) I'd like to be able to re-format /dev/sda1 to ext4 and then restore my 'most recent set of unscrewed up by rob' files.
I have never created a cron job, and worse, I have never created a .sh file which, I think, is what I need to do.
Any input on this lofty plan would be appreciated.
In addition to what others have said, you may want to look at the native dump and restore utilities for the filesystem you use. You don't specifically state what you are currently using, but you mention ext4. I have no idea if dump/restore support ext4. One of the reasons I use XFS is because of the excellent native backup utilities, xfsdump and xfsrestore. The man pages for those tools give decent examples of how to do incremental backups. For doing filesystem backups I see no reason to look beyond the native tools provided by your filesystem. The output can be piped through SSH to provide remote backups and restores, and piped through gzip/bzip2/xz/etc. for compression.
I would avoid using dd for automated backup purposes. It doesn't take free space in to account, and you need to restore to a filesystem that is the same size or larger than the source (including free space).
I am still a bit confused by 'terminology', I think.
Clonezilla or dd to an 'image' requires that the 'restore' be made to a partition of equal or greater size, right?
Is it possible, and safe, to backup just the files (is that what is meant by 'native' backup?, dump & restore?) and then restore them to a smaller or larger partition and still have a working system?
I am talking about root and home of my Slackware 13.37 system.
If I have the terminology right, which is the safest or best: image backup or dump & restore? If they are equally safe, what is the difference & why choose one over the other?
you are doing a bit-by-bit copy of that partition. This includes free space, which is why you need to restore (dd if=/path/to/some/image_file of=/dev/some_partition) to a disk or partition of equal or greater size. It also takes a long time.
Quote:
Originally Posted by Robert.Thompson
Is it possible, and safe, to backup just the files (is that what is meant by 'native' backup?, dump & restore?) and then restore them to a smaller or larger partition and still have a working system?
Yes, it is possible and safe to backup just files and then restore them. There are many ways to do this. A filesystem's native dump and restore utilities (xfsdump and xfsrestore in my case) will back up the files and directories; maintain permissions, links, etc.; and possibly have more advanced features such as incremental backups/restores. You could also use cp or tar combined with gzip/bzip2/xz/etc to maintain compressed backups of your files and directories. The man pages of cp and tar should be closely examined to find the command line switches used for your specific needs (permissions, following links, excluding files, and so on). If what you want to do is backup complete filesystems, I would strongly encourage you to look in to native tools provided by the filesystem for the job.
Quote:
Originally Posted by Robert.Thompson
I am talking about root and home of my Slackware 13.37 system.
If I have the terminology right, which is the safest or best: image backup or dump & restore? If they are equally safe, what is the difference & why choose one over the other?
Thanks for any clarification,
Unless I missed it somewhere, you still haven't stated specifically what filesystem you use for your / and /home partitions. My own personal preference is using the dump and restore tools for the filesystem I use. After all, they are made for the job, and probably do it quite well. If you are using ext4 then you will need to figure out if the extfs dump and restore tools even support ext4. If they don't, then that obviously won't be an option for you. They did not when ext4 was new, but I have no idea what the current state is, as I don't use that fs.
Additionally, the term "image" can mean different things. Backup tools may make what they call an image of your partition. That could be anything, from a compressed copy certain files, to a bit-by-bit copy such as done by dd. So it isn't as simple as either an image or using a filesystem specific dump tool. There are many ways to skin this cat.
Both backups are needed. Saving image of a partition protects your system. From other hand it may be impossible to restore the image in the way you get a working system - eg. restoring on a different computer (or the same but with a different hardware setting) may be an obstacle.
So you need to make a backup of your files using cpio or simple tar+gz.
I use rsync to backup the files in my home directory.
rsync is great because it works incrementally - rsync'ing to an empty directory takes a long time, but subsequent rsync's with only a few differences are very quick. rsync will be much faster than an image copy.
I don't find a need to back up the root directory. Instead, I re-install the OS from the DVD if that ever becomes necessary. Almost all OS re-installs are to upgrade rather than to correct for pilot error.
Ed
I'll use rsync and love it and I use this little bash script that cron runs once a day.
Code:
#!/bin/bash
# This script does personal backups to a rsync backup server. You will end up
# with a 7 day rotating incremental backup. The incrementals will go
# into subdirectories named after the day of the week, and the current
# full backup goes into a directory called "current"
# tridge@linuxcare.com
# directory to backup
BDIR=/home/user
# excludes file - this contains a wildcard pattern per line of files to exclude
EXCLUDES=/home/user/backup_exclude.txt
# the name of the backup machine
BSERVER=192.168.9.10
# your password on the backup server
export RSYNC_PASSWORD=****
########################################################################
BACKUPDIR=`date +%A`
#BACKUPDIR="Sunday"
OPTS="--force --delete-excluded --exclude-from=$EXCLUDES
--delete --backup --backup-dir=/Workstation/$BACKUPDIR -av"
export PATH=$PATH:/bin:/usr/bin:/usr/local/bin
# the following line clears the last weeks incremental directory
[ -d $HOME/emptydir ] || mkdir $HOME/emptydir
rsync --delete -a $HOME/emptydir/ backup@$BSERVER::backup/Workstation/$BACKUPDIR/
rmdir $HOME/emptydir
# now the actual transfer
rsync $OPTS $BDIR backup@$BSERVER::backup/Workstation/current
And all this gives you:
ls backup/Workstation
Friday Monday Saturday Sunday Thursday Tuesday Wednesday current
I always rsync everything (also root). It soooo fast :-D and you can always recover root with 'chroot' - The imo most important tool for recovering a lost system.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.