1

Prior to reinstalling VPS and upgrading from Debian 6 to Debian 8, I have archived /etc/ folder. Now, I am trying to extract and overwrite everything, but somewhere in the process I get this message

Extracting  /etc/rc2.d/K01sendmail                                    OK
Extracting  /etc/rc2.d/S03maldet                                      OK
Extracting  /etc/rc2.d/S01rsyslog                                     OK
Extracting  /etc/login.defs                                           OK
Extracting  /etc/ucf.conf                                             OK
Extracting  /etc/memstat.conf                                         OK
Extracting  /etc/mtab                                                 OK
Cannot close the file /etc/mtab
Program aborted

What is this /etc/mtab and how can I prevent it from aborting my /etc/ folder overwriting?

I am doing rar x to extract over the current /etc. It looks like something broke down because it cannot boot anymore

  • 1
    What command are you using? Are you extracting over the existing /etc? This probably has something to do with /etc/mtab being a symbolic link. Beware that depending on what you're extracting and how, you may have overwritten other files that shouldn't have been overwritten without an obvious error message. – Gilles 'SO- stop being evil' Oct 15 '15 at 0:35
  • I am doing rar x to extract over the current /etc. It looks like something broke down because it cannot boot anymore – cikatomo Oct 15 '15 at 2:03
1

Ouch, are you really using rar? I don't think rar properly stores symbolic links, ownership and permissions. In /etc, that would break many many things. /etc/mtab is just one that happens to be a symbolic link to a read-only file, so you got an error for this one — but many other symbolic links were saved as regular files and while extracting them from the backup succeeded the end result is not a valid system. The worst problems would be from the permissions though — you can probably still boot with symbolic links replaced by their restored content (but then you'd run into problems whenever you install software) but not with broken permissions or ownership.

Use a native Unix tool such as tar, cpio or pax to back up system directories. Evem then, beware that some things won't work if you blithely extract a backup of /etc from a different installation on Debian, because some services use dynamically-assigned user and group IDs; when you restore /etc/passwd and /etc/group from a different bakcup, that will introduce an inconsistency between /etc and permissions elsewhere. I'm not sure if there's a good solution to that one if you just want to restore /etc as a whole.

You can't restore your rar backup. Reinstall the system, then extract the rar archive in a different directory. Figure out what files you modified on the original system (based on the dates, maybe) and copy only those. Don't copy any file you don't understand. In the user and group databases (/etc/passwd, /etc/group, /etc/shadow, /etc/gshadow), copy only the entries for human users, let Debian manage the system users.

Going forward, a much better way to back up /etc independently is to put it under version control. Etckeeper is great at that. Run etckeeper init after installation. When you make some change in /etc, run etckeeper commit and enter a message to describe your change (your future self will thank you). Push a copy of the repository to your backup area. To restore a backup, initialize etckeeper on the new system, add the backup as an external repository and merge it into the local branch.

  • Lot of stuff I didn't know in your answer. What about the other folders? I have /var, /usr/local. Is something gonna happen if I restore those? – cikatomo Oct 16 '15 at 2:20
  • @cikatomo /usr/local should be ok. /var might be a problem if some of the user or group IDs have changed. If you restore /etc and /var first and then reinstall all packages that use user IDs assigned dynamically, it should be ok, but it's not completely trivial to get it right. – Gilles 'SO- stop being evil' Oct 18 '15 at 19:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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