1

I have a RHEL server which acts as the web server for all the users (around 1000 users). Now, I have a backup script which backs up the data (all data inside /home folder) into an external HDD. This back up script is also in the cron.daily so that the backup will happen on a daily basis.

Hypothetical situation

Let us assume the RHEL web server crashed. I will build a new machine as a RHEL web server. I can paste the users' data that is already backed up in the external HDD into the new machine's /home folder.

But for the 1000 users' to access their home directories in this new machine, I need to create the 1000 users again. Is there a way I can save that data too from the existing machine before crash? I know /etc/passwd and /etc/groups will contain user related information. But if I save them, won't there be password issues?

  • Don't for get /etc/shadow !! – X Tian Feb 12 '14 at 0:30
  • So, if I copy these 3 files in the new machine, no need to create the user accounts? Also, will the users be able to access their home directories without the need to change passwords or something? – Ramesh Feb 12 '14 at 0:33
1

I generally suggest getting the following 8 files along with the contents of /home when you want to preserve the user's info on a given system. If any user's have sudo rights, you'll often want to back up the /etc/sudoers file too. Additionally you might want to get a dump of all the RPMs installed on the system. So here's how I would proceed.

$ ls /etc/{passwd{,-},group*,{,g}shadow*,sudoers}
/etc/group   /etc/gshadow   /etc/passwd   /etc/shadow   /etc/sudoers
/etc/group-  /etc/gshadow-  /etc/passwd-  /etc/shadow-

Example commands

$ sudo cp -p /etc/{passwd{,-},group*,{,g}shadow*,sudoers} /my/backup/dir/.
$ rsync -avz /home/* /my/backup/dir/homes/.
$ rpm -aq --liast > /my/backup/dir/rpm_list_$(date --iso-8601).txt

The contents of the list file will look like this:

mozilla-filesystem-1.9-9.fc19.x86_64          Sat 07 Dec 2013 08:46:35 PM EST
dejavu-fonts-common-2.33-5.fc19.noarch        Sat 07 Dec 2013 08:46:34 PM EST
telepathy-filesystem-0.0.2-5.fc19.noarch      Sat 07 Dec 2013 08:46:33 PM EST
setup-2.8.71-1.fc19.noarch                    Sat 07 Dec 2013 08:46:32 PM EST
fontpackages-filesystem-1.44-7.fc19.noarch    Sat 07 Dec 2013 08:46:31 PM EST
  • So after installing the new machine, if I copy these files along with the home directory, the user will not be even aware that the machine crashed and a new server was installed in place of that? – Ramesh Feb 12 '14 at 1:40
  • @Ramesh - correct! I also use this as a method for backing up key things on the system. If you're running a webserver you'll want to backup /var/www as well. – slm Feb 12 '14 at 1:41
  • Most of the RH distros are fairly disposable in this way. – slm Feb 12 '14 at 1:42
1

The passwords are stored in /etc/shadow and there's also /etc/shadow-, yes I would say that would work.But test it, try on one user to start with.

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.