Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Does it make sense to backup the entire /home directory? Or should I selectively backup the config files I want to retain?

If I reinstall the OS, is it safe to use the previous /home directory if it's the same distro?

share|improve this question

4 Answers 4

up vote 3 down vote accepted

Absolutely. It makes perfect sense to backup your whole home directory.

I'd only recommend restoring the entire directory if it's the same version of the same distribution. If you're restoring to a different version, extract individual config files from your backup as needed.

I'd restore Firefox profiles, Vim config files, bash config files & aliases, and (probably) my ~/bin directory -- but I wouldn't restore Gnome config files. I'd let the new Gnome version create config files from scratch and then apply changes a few at a time.

YMMV, though, and if something blows up after you restore your entire home directory, it's not too hard to remove your config files and let programs recreate them the next time they run.

share|improve this answer

I can tell from the question you're a newbie to this sort of thing... Over the holidays I just retooled my backup / archival / recovery strategy that I've had in place for FOURTEEN years. Here's some great advice...

First, Richard Marquez has it right - another partition, but I have simplified this and standardized it for my use - here you go:

The directory "slash el", /l, is where the "local" things go that I care about. Nothing that's a part of the operating system goes here.

The directory /nfs is where all "foreign" file systems get mounted, and subdirectories for each host are underneath - and under that is where that system's "slash el" directories go.

Disk space - ALL - non-system disk space goes under /d with a mount point per disk as in:

/d/d1
/d/d2
/d/d3

These disks then contain whatever. Your /l directory then links to these places. For example, music might be in /d/d3/Music, and /l has then /l/Music. You can them move Music around when needed and just change the link. The link is made with ln, for example:

ln -s /d/d3/Music /l/Music


The point here is to organize in advance using a pattern that's easy to remember and easy to manage. When you get new disks, you already have a place to put them and you already have a way to move data between them simply and easily. AND you know where the "primary" copy is, because, in my example, it's under /l.


Now, for backups, put them on their own spindle, say /d/d2/Backups. Now you have a link /l/Backups, so you never have to worry what spindle the data's on. Under that you have a place for zip files and tars if you like, say /l/Backup/zip. But, vitally, I also use a place I call "sync" and this is where things get really useful...

If you have a directory under /l/Backups/sync for each directory under /l except Backups, you can then use this fantastic tool called rsync. It's so useful I can only introduce you to it here... You then synchronize your backup space with rsync with something like:

rsync /l/Music /l/Backups/sync

Under /l/Backups/sync, you'll then have a directory called Music that contains THE ENTIRE TREE, and not in a zip but as live files. Further, rsync is so smart, it only touches the things that have changed so it's very efficient. You can synchronize huge trees in a matter of minutes, depending on the changes. It will even delete deleted files if you want so the trees remain EXACTLY the same, including permissions, timestamps, etc.

I have found this so useful, I have created a backup script which uses all my favorite flags and keeps me from having to even think about it - just call the script and it makes it happen.

Rsync is designed to help you synchronize disks ACROSS SYSTEMS, and it knows how to use SSH, so you can kee REMOTE disks synchronized, too - great for disaster recovery!

Hope this helps... There's a lot possible - take a word from the wise: Keep all your own stuff completely separate from the operating system and back the OS up separately. If you are using Unix or Linux, all you really need is /etc. There shouldn't be much else... DO NOT LET YOUR STUFF GET MINGLED WITH THE OS!

share|improve this answer
1  
imo this is bad usage of unix file system hirarchy –  matthias krull Feb 16 '11 at 22:45
    
@mugenkenichi could you expand on that? i don't think it's such a bad idea as i use something like this. –  Dan D. Dec 17 '11 at 21:54

Being a bit pickier than just making a backup of the whole home directory has some advantages:

  • you will learn that sometimes you might need a couple of versions of the same config/source code file, which will push you toward storing such data by using an intermediate layer - a Source Code Management tool and creating a backup of the repository
  • you will learn that there are things in your home directory that you certainly wouldn't want to backup. For example the cache directory from your Firefox profile.
share|improve this answer
    
In addition to the firefox profile I exclude ~/UbuntuOne (because it is in the cloud anyway) and large caches like the trackerd cache and ~/.googleearth/cache. This saves a lot of space. –  Ludwig Weinzierl Jan 24 '10 at 8:40
    
good point about the cache directories. excluding them easily depends on the backup tool, but you're right, they aren't necessary at all. –  quack quixote Jan 24 '10 at 13:34

In regards to the first part of your question, it really depends if the contents of your /home is something you want to keep (discounting your configs which as you stated, you do).

As far as being safe to use the same /home directory, I would really recommend putting it on a separate partition and mounting it on boot. This saves the trouble of having to back it up and restore it each time you re-install a distro. The only problem I've ever had with using an "old" /home is that you may need to change the ownership after a new distro install (i.e. sudo chown -R yourname /home/yourname).

If you do decide to backup just your configs, I really recommend putting them on GitHub rather than locally (it's just plain easier in my opinion). I usually make a backup directory and hard-link all my configs into that directory, turn it into a git repository and have a cron job push it to github every so often. From experience, I can tell you that this really helps if you suddenly need to re-install (I hate you fdisk...) but didn't have recent backups.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.