||1st June 2010 15:45
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
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
45 23 * * * /root/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
# echo $date
# echo $BACKUPNAME
for i in $(echo 'SHOW DATABASES;' | mysql -u$USER -p$PASSWORD -h$HOST|grep -v '^Database$'); do
-u$USER -p$PASSWORD -h$HOST \
-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/
==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==
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
||21st December 2010 10:09
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:
||21st December 2010 12:57
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:)
||23rd December 2010 10:05
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.
||28th May 2012 17:33
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.
|All times are GMT +2. The time now is 16:04.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.