Ask Your Question

rsync boot disk dirs to exclude

asked 2016-02-07 13:14:58 -0500

zug234zwang gravatar image

I've installed Fedora 22 to my boot hard disk, which is assigned device=sda. It has the following directory structure:

.autorelabel, bin, boot, .config, dev, etc, home, lib, lib32, lib64, lost+found, media, mnt, opt, proc, root, run, sbin, srv, sys, tmp, usr, var

I've also installed Fedora 22 to an external (hard disk) docking station, which is assigned device=sdc. I plan to periodically use rsync to maintain device=sdc. My tentative list of directories to exclude is:

/dev, /home, /media, /mnt, /proc, /run/media, /sys, /tmp, /var/lock, /var/run

/home is excluded because I rsync it separately. Ideally, device=sdc simulates a clone of device=sda. As a fairly inexperienced Linux user, I request discussion of directories to exclude.

edit retag flag offensive close merge delete


Whatever backup solution/method you choose, from the list in your question...


  • /home including the hidden .files and .folders
  • /etc (I know, not on your list)


  • /dev
  • /media
  • /mnt
  • /proc
  • /run/media
  • /sys
  • /tmp
  • /var/lock
  • /var/run

Some people also backup a list of installed packages to speed up the restore process. Just search the net a little bit on backup methods for Linux. There is plenty of information. Regarding sync , you start here:

florian gravatar imageflorian ( 2016-02-08 10:56:20 -0500 )edit

To me, it's not clear what you want to achieve? A full backup of your harddrive in case your main one goes bad? Or just a backup of the important things in case you need/want to reinstall your OS? For the latter, backing up /home including all hidden .files and .folders (!) is sufficient, adding /etc to the backup can be useful too. (Servers need more backup!)

florian gravatar imageflorian ( 2016-02-08 11:12:56 -0500 )edit

Check out this one here too!

florian gravatar imageflorian ( 2016-02-08 11:57:26 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2016-02-08 16:07:45 -0500

zug234zwang gravatar image

updated 2016-02-10 08:47:44 -0500

The web page "re-located" my "answer", which was my response to Florian's comments. Logically, my answer should immediately precede the comment: "Here is how I would do it. Your plan sounds good..."

Below given as an answer because I didn't want to split my reply into multiple comments.

Very interesting comments, thanks florian. Goals:

a. A full backup of my harddrive in case my main one goes bad.

b. Ability to boot the backup hard drive from either the docking station (device = sdc) or as a replacement hard disk (device = sda). This gives me flexibility in a restore situation and facilitates "rolling back" the main boot drive (using device=sdc to restore device=sda), in case a "bad" package is installed, without having to open my pc case.

c. After booting with the backup harddrive, all installed packages should be present; no need to re-install packages.

After reading your comments I have two followup questions:

(1) re goal b above, and noting that /boot will be included and /dev excluded from the rsync, I believe that I will need special handling for /etc/fstab and /boot/grub2/grub.cfg. I will probably create fstab_original and grub_original.cfg on my main boot disk (just before each rsync) and then specifically exclude /etc/fstab and /boot/grub2/grub.cfg from the rsync. This should allow the backup to boot from the docking station (device = sdc). If I ever need to swap the backup for the original boot (i.e. move the backup into device=sda), I will first boot Fedora 22 live from a separate flash drive and replace fstab and grub.cfg with their ..._original counterparts, on the backup.

Is this workable/practical? Are there other areas that will also need special handling?

(2) re goal c above, I was surprised to encounter the following recommendation:

rpm -qa | tee installed_packages.list

I presumed that all installed packages would automatically be replicated by the rsync. Doesn't that make the above command obselete? What am I missing?

edit flag offensive delete link more

answered 2016-02-09 14:05:02 -0500

florian gravatar image

updated 2016-02-11 09:29:07 -0500

Here is how I would do it. Your plan sounds good but in my personal opinion it's a bit overdoing. (And it get's quickly messy when it comes to cloning partitions and drives in an LVM setup.)

Maintain a full backup of your system (/home, /etc, and list of installed packages) on external (or better two) hard drives (or cloud or whatever), using rsync or BackInTime (space saving snapshot method) regularly*.

In case your internal drive goes bad, insert a new one, install Fedora, restore /home, /etc , and the previously installed packages and done. (I understand the disadvantage that it may take something between hours and days to get a replacement drive).

In case you install a "bad" package as mentioned in your comment (answer), just uninstall it (dnf history undo <i>). If that bad package leaves you with a non-bootable system, boot a live disc, and repair the system.

If you don't like this plan, you could still do the following: Install Fedora on your sda drive, install all your custom extra packages. Then, install Fedora on the second (sdc) drive, install the extra packages (using the exported list from sda system), and then do a regular* sync (using rsync or backintime) of /home (and maybe /etc) from sda to sdc system. In that case your sdc system is kind of stand-by but always bootable, and has a recent backup of /home. All you would have to do when you really need it is an upgrade on your stand-by system, which should be quick and straightforward.

To better understand and decide what to include/exclude in your backup or syncing/cloning process, read something about the filesystem structure of GNU Linuxes, e.g. this:

*: You can define what regular means, anything from hourly to monthly is accepted... ;-)

edit flag offensive delete link more


Below given as a series of comments because I didn't want to edit my original response (answer), and I'm not allowed a 2nd "answer".

Very interesting, thanks. Again followup questions:

(1) I'm surprised that package-reinstalling is apparently preferred to my idea of a full rsync on the root (with specific directories excluded). This suggests that either my idea is problematic or that hard disks fail infrequently enough that it is overkill to keep the external hard disk (e.g. device=sdc) up-to-date (besides /home and /etc).

Has anyone tried my approach? Is it problematic?

zug234zwang gravatar imagezug234zwang ( 2016-02-09 17:16:55 -0500 )edit

(2) I'm newbie-daunted by researching dnf. Assume that I have a list of installed packages re [rpm -qa | tee installed_packages.list] or a similar dnf command. Also assume that I've just used a Fedora 22 Live (flash drive) to install Fedora 22 onto a hard disk and then booted from this hard disk, with the package list accessible.

How do I use the list to re-install the packages; I welcome sample command(s)?

zug234zwang gravatar imagezug234zwang ( 2016-02-09 17:17:31 -0500 )edit


If that bad package leaves you with a non-bootable system, boot a live disc, and repair the system.

Does this mean (for example) to boot with a flash drive that contains Fedora 22 Live, and then use utilities on the flash drive against the hard disk containing the non-bootable system? Which utilities; I welcome sample command(s)?

Alternatively, do I first use the flash drive to install Fedora 22 onto an "extra-hard-disk" et al, and then boot from and use utilities on the "extra-hard-disk"? Again, which utilities?

zug234zwang gravatar imagezug234zwang ( 2016-02-09 17:19:18 -0500 )edit

(4) Continuting the last question, assume that the last package installed is bad, I have uninstalled via (dnf history undo ...), the resulting system is non-bootable, and I successfully repair the system. Does this mean that the repaired system approximates the system just before the last package was installed? If not, is the difference "significant"?

zug234zwang gravatar imagezug234zwang ( 2016-02-09 17:20:38 -0500 )edit

The web page "re-located" my "answer", which was my response to Florian's comments. Logically, my answer should immediately precede the comment: "Here is how I would do it. Your plan sounds good..."

zug234zwang gravatar imagezug234zwang ( 2016-02-09 17:44:11 -0500 )edit

Question Tools



Asked: 2016-02-07 13:14:58 -0500

Seen: 327 times

Last updated: Feb 11 '16