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.
Best Answer
There are very few files that absolutely must be different between two machines, and need to be regenerated when cloning:
/etc/hostname
./etc/ssh_host_*_key*
or/etc/ssh/ssh_host_*_key*
or similar location./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./etc/modules
,/etc/modprobe.conf
,/etc/modprobe.d/
and/etc/modutils/
.In addition, some network configuration may need to change, in particular:
/etc/network/interfaces
on Debian,/etc/sysconfig/network
on Red Hat)./etc/hosts
often contains the host name./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).