webcp.hostinghacks.net/slackware | rebuild production server
rebuilding a production server
The installation commands can be run from a Putty window in a "cut-and-paste" style layout or copied to a script. Notes on Putty best practices can be found here.
Backup files in /etc:
mkdir -p /home/backup cd /etc tar -zcpvf /home/backup/etc.tar.gz \ passwd \ shadow \ group \ gshadow \ proftpd.conf \ httpd/conf/httpd.conf \ aliases \ mail/access \ mail/local-host-names \ mail/virtusertable \ cron.hourly/* \ cron.daily/* \ cron.weekly/* \ named.conf \ webalizer.conf \ syslog.conf \ logrotate.conf \ shells \ warnquota.conf \ rc.d/init.d/webcp \ mrtg/* \ sysconfig/network \ sysconfig/network-scripts/ifcfg-eth0
Backup /var files
mkdir -p /home/backup cd /var tar -zcpvf /home/backup/var.tar.gz \ lib/mysql/* \ lib/mod_watch/* \ named/* \ spool/mail/* \ ## imap/*
Backup /home files:
mkdir -p /home/backup cd /home tar -zcpvf /home/backup/1.tar.gz 1* tar -zcpvf /home/backup/2.tar.gz 2* tar -zcpvf /home/backup/3.tar.gz 3* tar -zcpvf /home/backup/4.tar.gz 4* tar -zcpvf /home/backup/5.tar.gz 5* tar -zcpvf /home/backup/6.tar.gz 6* tar -zcpvf /home/backup/7.tar.gz 7* tar -zcpvf /home/backup/8.tar.gz 8* tar -zcpvf /home/backup/9.tar.gz 9* tar -zcpvf /home/backup/webcp.tar.gz webcp/* tar -zcpvf /home/backup/webmail.tar.gz webmail/* tar -cpvf /home/backup/sym+quota.tar *.*
Export the mysql webcp data and schema to a text file:
mysqldump -u root -p webcp > /home/backup/dump.sql
scp the tar.gzipped files to a remote server:
scp /home/backup/* devel.hosting.hacks:/home/restore
/home data
cd /home tar -zxpvf /home/restore/1.tar.gz tar -zxpvf /home/restore/2.tar.gz tar -zxpvf /home/restore/3.tar.gz tar -zxpvf /home/restore/4.tar.gz tar -zxpvf /home/restore/5.tar.gz tar -zxpvf /home/restore/6.tar.gz tar -zxpvf /home/restore/7.tar.gz tar -zxpvf /home/restore/8.tar.gz tar -zxpvf /home/restore/9.tar.gz tar -zxpvf /home/restore/webcp.tar.gz tar -xpvf /home/restore/sym+quota.tar
/var
cd /var tar -zxpvf /home/restore/var.tar.gz
/etc
cd /etc tar -zxpvf /home/restore/etc.tar.gz
Transfering Data to a USB Drive
Hot-plug a USB drive and confirm that the OS found it:
tail -f /var/log/messages Oct 29 17:02:22 subzero kernel: SCSI subsystem driver Revision: 1.00 Oct 29 17:02:22 subzero kernel: Initializing USB Mass Storage driver... Oct 29 17:02:22 subzero kernel: usb.c: registered new driver usb-storage Oct 29 17:02:22 subzero kernel: scsi0 : SCSI emulation for USB Mass Storage devices Oct 29 17:02:22 subzero kernel: usb-uhci.c: interrupt, status 3, frame# 2001 Oct 29 17:02:22 subzero kernel: Vendor: Generic Model: STORAGE DEVICE Rev: 1.25 Oct 29 17:02:22 subzero kernel: Type: Direct-Access AN Oct 29 17:02:22 subzero kernel: USB Mass Storage support registered. Oct 29 17:02:23 subzero devlabel: devlabel service started/restarted
partition the drive:
fdisk /dev/sda
format it and mount the drive:
mkfs.ext3 /dev/sda1 mkdir /mnt/usb mount /dev/sda1 /mnt/usb
start the backup:
cd / tar -zcpvf /mnt/usb/system.tar.gz \ bin/* \ sbin/* \ lib/* \ usr/* \ etc/* \ var/* \ home/*
umount /mnt/usb
Rebuild the system by reformatting with the kickstart file (use the same partitioning scheme!) then boot the system, mount the drive and restore the system:
mkdir /mnt/usb mount /dev/sda1 /mnt/usb cd / tar -zxpvf /mnt/usb/system.tar.gz
reboot the system.