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
|
Recent comments
7 hours 34 min ago
12 hours 26 min ago
21 hours 19 min ago
22 hours 18 min ago
1 day 2 hours ago
1 day 3 hours ago
1 day 6 hours ago
1 day 14 hours ago
1 day 23 hours ago
2 days 37 min ago