4

I am doing a restoration test of backup files on a computer. Without putting much thought into it, I did an rsync to replace all files in /etc folder with the ones in the backup. Then, I realize I shouldn't really be doing it as the passwords and user names for the two computers are not the same.

After a reboot, the computer is in a state where it cannot start, and I would possibly have to reinstall it from scratch. Now my question is, given the same OS, what are the files in /etc folder that are unique for each computer. This would allow me to fine-tune rsync to exclude those files in the future when doing a restoration from backup.

  • You might want to boot into rescue mode and fix /etc/fstab. That's probably the main thing that's stopping you from booting up. – Bratchley Aug 17 '14 at 12:33
  • 2
    But this idea of rsync'ing the whole /etc tree is bad to begin with. This sort of thing is why backup systems have automated de-duped logic. Definitionally anything under /etc can vary from system to system. – Bratchley Aug 17 '14 at 12:37
  • @JoelDavis, thanks for pointing out that my approach is not correct. This is the first time I am doing it. Does it mean that I have to go through all config files one by one? I am hoping for a less tedious approach. – Question Overflow Aug 17 '14 at 13:38
  • Is there a reason you can't just rsync the /etc on each node and just use tar cjpf server side? That wouldn't use much additional space since most of the files are text. That's better than picking through each node's /etc looking for files that are different. – Bratchley Aug 17 '14 at 14:13
  • Either that or use an enterprise backup system that will take care of de-dupe for you and you can just backup the entire system and not worry about it. – Bratchley Aug 17 '14 at 14:15
  • @JoelDavis, for backup itself, I am using duplicity. I just want to test the backup by restoring it on another computer. – Question Overflow Aug 17 '14 at 14:49
  • If you're doing a bare metal restore to the other computer, you should be able to get away with just making sure the filesystems look identical. Usually BRE's boot to a temporary environment, though. – Bratchley Aug 17 '14 at 16:06

1 Answers1

4

There are very few files that absolutely must be different between two machines, and need to be regenerated when cloning:

  • The host name /etc/hostname.
  • The SSH host keys: /etc/ssh_host_*_key* or /etc/ssh/ssh_host_*_key* or similar location.
  • The random seed: /var/lib/urandom/random-seed or /var/lib/random-seed or similar location. (/var/lib/systemd/random-seed on systems using systemd)

Anything else could be identical if you have a bunch of identical machines.

A few files are typically different on machines with different hardware:

  • /etc/fstab, /etc/crypttab, /etc/mdadm.conf, and bootloader configuration files (if located in /etc — some distributions put them in /boot) if disks are partitioned differently.
  • /etc/X11/xorg.conf, if present, if the machines have different graphics cards.
  • Modules to load or blacklist in /etc/modules, /etc/modprobe.conf, /etc/modprobe.d/ and /etc/modutils/.

In addition, some network configuration may need to change, in particular:

  • If you have static IP addresses, they need to be diversified per machine. The location of IP configuration varies between distribution (e.g. /etc/network/interfaces on Debian, /etc/sysconfig/network on Red Hat).
  • /etc/hosts often contains the host name.
  • Mail configuration often contains the host name: check /etc/mailname.

There's no general answer to “what are the files in /etc folder (…) are unique for each computer” because the whole purpose of /etc is to store files that can be customized on each computer. For example, if you have different accounts on different machines, then obviously you can't share the account database — and if you want to be able to share the account database, then you'll end up with the same accounts.

Generally speaking, don't try to share /etc by default unless you have a set of machines with the same software configuration — same installed software, same accounts, etc. If you do share /etc, you'll need to blacklist a few files from sharing as indicated above.

If you have machines with different configurations, then whitelist what you synchronize. Treat files in /etc as distinct on different machines, like files in /var. Synchronize only the ones that you've decided should apply everywhere.

One possible way to manage synchronization is to keep machine-specific files in a different directory, e.g. /local/etc, and make symbolic links like /etc/fstab -> ../local/etc/fstab. This still requires a largely homogeneous set of machines in terms of software as different distributions put files in different locations. Or, conversely, keep only the machine-specific files in /etc and all generic files elsewhere — but typical distributions don't accommodate this well.

You obviously can't do a live test of the restoration of the system configuration of one system on a different system. To test the restoration of your backups, fire up a virtual machine that emulates the hardware configuration sufficiently well (in particular, with a similar disk layout).

yt7b97q-
  • 145