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
Prev Previous Post   Next Post Next
  #1  
Old 1st June 2010, 14:45
Morons Morons is offline
Senior Member
 
Join Date: Aug 2006
Posts: 189
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

Quote:
=BACKUP=
Make Crontab entry
crontab -e
45 23 * * * /root/make-backup

===vi /usr/bin/make-backup===
<pre>#!/bin/bash
find /root/ispconfig > /root/backup-files
find /home/admispconfig >> /root/backup-files
pwunconv
grpunconv
find /etc >> /root/backup-files
pwconv
grpconv
find /var/www >> /root/backup-files
find /var/backups >> /root/backup-files

DATE=`date +%Y-%A`
BACKUPNAME="use-yr-server-name-here-"$DATE
# echo $date
# echo $BACKUPNAME
USER=root
PASSWORD=use-yr-own-password-here
HOST=localhost
DESTINATION=use-yr-destination-server-fqdn-or-ip-here

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

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>

=RESTORE=
==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
pwck
and
grpck
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
tar xvfz YOURBACKUPFILENAME.tar.gz
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 14: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
 

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


All times are GMT +2. The time now is 23:49.


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