Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 2 > Tips/Tricks/Mods

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Thread Tools Display Modes
Old 1st June 2010, 15:45
Morons Morons is offline
Senior Member
Join Date: Aug 2006
Posts: 199
Thanks: 8
Thanked 15 Times in 7 Posts
Default Moron's Backup Script ISPConfig 2

I have backup'ed up and sucessfully re-created servers with this scrips or like skipt a few times now

Note on restore:
The most difficult part is to sort out the /etc/passwd and /etc/group after - basically the proscess is as follow
pwunconv to get the passwords in the passwd file and same with grpunconv
then merge the old file by copy-paste or remove the system users and groups from the source and append it. Carefull with group users.

I copied my wiki file here - to lazy to convert to bb enjoy. Additionally I install backuppc and use a cron to daily transfer the backedup data to a UBS extranal drive

Make Crontab entry
crontab -e
45 23 * * * /root/make-backup

===vi /usr/bin/make-backup===
find /root/ispconfig > /root/backup-files
find /home/admispconfig >> /root/backup-files
find /etc >> /root/backup-files
find /var/www >> /root/backup-files
find /var/backups >> /root/backup-files

DATE=`date +%Y-%A`
# echo $date

for i in $(echo 'SHOW DATABASES;' | mysql -u$USER -p$PASSWORD -h$HOST|grep -v '^Database$'); do
mysqldump \
-Q -c -C --add-drop-table --add-locks --quick --lock-tables \
$i > /home/backup/$BACKUPNAME-$i.sql;

tar cvzf /home/backup/$BACKUPNAME"-backup.tar.gz" --files-from=/root/backup-files --no-recursion
/usr/bin/scp /home/backup/$BACKUPNAME* $DESTINATION:/home/backup/
rm /root/backup-files</pre>

==fix the passwd file==
rename the backed-up ''passwd'', ''group'', ''shadow'' and ''gshadow'' file(s) to something like ''passwd.old'' etc.
remove the "system" users and make sure you syncronise them in the passwd/shadow as well as the group/gshadow.
If you stil have the old system runnig use ''pwunconv'' and ''grpunconv'' commands and then the shadow filew are merged into he ''passwd'' and ''group'' files, this make it lot easier to edit and remove all "non-ispconfig" users and groups.
Once done then use commands like
cat passwd.old >> /etc/passwd
cat group.old >> /etc/group
Incase you used ''pwunconv'' and ''groupunconv'' you need to use ''pwconv'' and ''grpconv'' to create new shado files
you can test the files and delete / repair them using the command
Read carefull and answer the questions if any. ignore the "missing" home directories this will be installed later
==restore the /home & /var directory==
cd /tmp
mv /tmp/var /var
do the same with all backup directories ypou want to restore

'''Caution:''' when restoring /etc it can have extremely bad results!

==import mysql data==
Once you have the .sql files available
mysql -u root -p
then create the databases one by one
create database yoursqldatabase;
Quit from mysql and start copy the sql dump files intot he databases
mysql -u root -p -e "source /home/backup/servername-date-Friday-db_ispconfig.sql" db_ispconfig

Last edited by Morons; 1st June 2010 at 15:48.
Reply With Quote
The Following 5 Users Say Thank You to Morons For This Useful Post:
atrika (24th August 2010), DomainAdmin (28th May 2012), falko (2nd June 2010), madmucho (30th November 2010), scottrill2 (26th July 2010)
Sponsored Links
Old 21st December 2010, 10:09
bas bas is offline
Junior Member
Join Date: Jan 2008
Location: Amsterdam
Posts: 12
Thanks: 1
Thanked 0 Times in 0 Posts
Default Permissions

Thanks very much for this script

I've used it so far in parts - cause i didnt get it fully to work.
(but am sure that's somethign i can fix)

One potential issue.
Shouldnt the tar command also have the p option?

After i restored the files, all permissions on the directories were missing.

So shouldnt it be:
tar cvfzp

Thanks again
Reply With Quote
Old 21st December 2010, 12:57
Morons Morons is offline
Senior Member
Join Date: Aug 2006
Posts: 199
Thanks: 8
Thanked 15 Times in 7 Posts
Default Sample

It is meant to be customize by someone that know Bash +

I don't recommend p or rather P because it saves the leading / causing the restore to overwrite potentially a bad idea, rather restore some ware else and move/copy the needed files

I have further developed this a lot if you need assistance just shout
Reply With Quote
Old 23rd December 2010, 10:05
bas bas is offline
Junior Member
Join Date: Jan 2008
Location: Amsterdam
Posts: 12
Thanks: 1
Thanked 0 Times in 0 Posts
Default thanks


thanks for your answer.
And i agree - storing the full path isnt a wise plan. Just wanted to see a way to include the permissions.

Do you mean you have a new version ?
I got my server running good again. So either i'll go and adapt the one you posted here, or if you have an improved version then perhaps that would be wiser.

Reply With Quote
Old 28th May 2012, 17:33
DomainAdmin DomainAdmin is offline
Junior Member
Join Date: May 2012
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts

I have a question. I tried using this script and it at times fails to success connect or hold the connection to the FTP server.

So, how can it auto-email me with a status report (success and/or failure), and before stating a new "run", it checks the "backup-files" for old stuff and deletes them first prior to starting a new run.

Rather this, I have two drives in the dedicated server, wish I could "clone" one to the other automatically. or even have it sync the ISPConfig from the master drive to the 2nd drive.
Reply With Quote


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
ISPConfig Backup Script vaio1 General 14 13th November 2009 15:23
Upgrade failed, no ISPconfig, no backup... gauthier Installation/Configuration 4 19th April 2008 20:21
backup mx with ispconfig and postfix the_spy General 4 18th May 2007 11:19
Possible to install backup DNS or better backup whole ISPconfig server ? Snowman General 1 2nd May 2007 15:01
SP-Server Setup - Ubuntu 5.10 "Breezy Badger" - Page 6 (changes) LuisC-SM HOWTO-Related Questions 0 21st April 2006 16:16

All times are GMT +2. The time now is 22:47.

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