Prev Previous Post   Next Post Next
  #12  
Old 18th August 2010, 00:32
dcy dcy is offline
Junior Member
 
Join Date: Jul 2010
Posts: 24
Thanks: 0
Thanked 2 Times in 2 Posts
Default ... /etc/shadow and /etc/gshadow broken ...

Well, I was blessed by this bug today also

From what I was able to ascertain it seems that writeconf.php was somehow interrupted while writing out /etc/passwd, /etc/shadow, /etc/group and /etc/gshadow. The end result was an incomplete /etc/shadow (6k instead of 30k) and a completely empty /etc/gshadow.

Fixed it by rebooting and restoring the files from a backup (lost a few users passwords in the process, but still better than nothing).

I am not sure how ISPConfig 2.x writes out these files, but might I suggest that they be written to .ispconfig first and then just copied over to their real counterparts, so in case the process of writing out is interrupted only the .ispconfig bit is broken, and there is no headache involved. Of course if these files are written out with system calls this approach is not feasible.

To explain what I mean ...

1) writeout to /etc/passwd.ispconfig, /etc/shadow.ispconfig, /etc/group.ispconfig, /etc/gshadow.ispconfig (depending on the amount of users this could take a few seconds, where an interruption would be rather critical and system breaking).

After this process is done:
cp /etc/passwd.ispconfig /etc/passwd
cp /etc/shadow.ispconfig /etc/shadow
cp /etc/group.ispconfig /etc/group
cp /etc/gshadow.ispconfig /etc/gshadow


These 4 copies should take a lot less than the process of writing out the .ispconfig files themselves.

Be it as it may ... wrote a short backup script that I run several times a day now to save me any further headaches :]

Code:
#!/bin/bash
#
# Short backup of ETC - run 4 times daily - keep 120 copies
#
export DATUM=`/bin/date +%Y-%m-%d-%H%M`
echo `/bin/date` - Started >> /var/log/etc-backup-log
cd /data0/backups/etc
mkdir $DATUM
cd $DATUM
tar czvf etc.tgz /etc
echo `/bin/date` - Ended >> /var/log/etc-backup-log
cd /data0/backups/etc
let BACKUPS=`/bin/ls -dlt /data0/backups/etc/????-??-??-????|/usr/bin/wc -l`
while [ $BACKUPS -gt 120 ]; do
        ERASING="`/bin/ls -1dt /data0/backups/etc/????-??-??-????|/usr/bin/tail -1`"
        /bin/echo `/bin/date` - Erasing $ERASING  >> /var/log/etc-backup-log
        /bin/rm -f $ERASING/etc.tgz
        /bin/rmdir $ERASING
        let BACKUPS=`/bin/ls -dlt /data0/backups/etc/????-??-??-????|/usr/bin/wc -l`
done
Might be a bit on the quick and dirty side, but it does what I want it to I run it 4 times daily and keep 120 copies (so for 30 days back). On my server this amounts to approximately 1 GB of storage for the full 120 copies.

To use it, please check the paths for:
ls, rm, rmdir, echo, date, wc and change the script if necessary to reflect the right paths for your system.

The data is stored to /data0/backups/etc/ under timestamped directory names. (change the path accordingly in the script above if you keep it in a different place - there should be 5 changes involved - that's just because I'm lazy and didn't use a variable to store the path ). If you want to keep less than 120 copies, change the -gt 120 to -gt <copies>.

Copy the script to /bin/backup-etc.sh, chmod +x /bin/backup-etc.sh, put it in crontab:

Code:
15 3,9,15,21 * * * /bin/backup-etc.sh &> /dev/null
and save a headache

D.

Last edited by dcy; 18th August 2010 at 03:15.
Reply With Quote
The Following User Says Thank You to dcy For This Useful Post:
bernholdt (27th August 2010)
 

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy compiled php5 to another machine cooljai Installation/Configuration 4 11th October 2007 16:15
Migration from a virtual machine to physical sonoffett Technical 3 15th September 2007 16:09
How to connect to a Linux machine using VB rocket1356 Programming/Scripts 4 24th June 2007 19:48
connecting to windows machine sudha General 0 29th January 2007 13:38
I cannot resolve www.example.com on the local machine braakiss Installation/Configuration 5 12th January 2007 15:58


All times are GMT +2. The time now is 09:30.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.