Howto: Full DirectAdmin backup

ProWebUK

Verified User
Joined
Jun 9, 2003
Messages
2,326
Location
UK
Edit added 09/23/05 by jlasman:
I know this has been posted in a few places, but I can never find it online when I want to refer to it, so here it is:

This is the list of files and directories we recommend backing up for a DA restore:

Directories:
/etc/mail
/etc/virtual
/home/admin
/usr/lib/apache
/usr/local
/usr/share/ssl
/var/log
/var/mail
/var/named
/var/spool/cron
/var/spool/mail
/var/spool/virtual
/var/www
/usr/local/directadmin/data/admin

Files:
/etc/exim.conf
/etc/exim.crt
/etc/exim.key
/etc/exim.pl
/etc/group
/etc/gshadow
/etc/hosts
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/ips.conf
/etc/named.conf
/etc/passwd
/etc/proftpd.conf
/etc/proftpd.passwd
/etc/proftpd.vhosts.conf
/etc/resolv.conf
/etc/shadow
/etc/ssh/sshd_config
/etc/system_filter.exim
/usr/local/directadmin/conf/mysql.conf

Of course we make no guarantees of any errors or omissions in this list; you're responsible for your own server backup.


Edit added 03/0/05 by jlasman:
It's no longer necessary to download and install sysbk into DirectAdmin as it's now included in the DirectAdmin installation and completely configurable through the admin level DirectAdmin control panel.


Well to keep things clean and simple its based on sysbk, a great script released by r-fx networks with 2 modules included for ensim and cpanel aswell as default support for such files as your mysql configs the mysql init script mysql dump and myisamchk binaries aswell as named config files and zone files - finally your apache directory also gets backed up - /etc/httpd

Its a very simple to use system, everything is done for you, basically theres a config file for you the rest is thoroughly checked by a built in md5 checker on most packages within it, a variable to allow the maximum load sysbk will run under (default value is 2 - anything higher sysbk wont make the backup at the time) and also a minimum disk space that you specifiy to perform backups.

Backups can be moved using FTP or SCP (SSH)

Before we get onto the installation and porting for directadmin here is the feature list from the website:

.: Summary of features:
- all backup operations have a companion .md5 file with md5sum of the original files, to ensure data integrity
- capable of using a secondary archiving utility such as bzip2
- easy configuration of backup path and mount points
- configurable load-level threshold for performing backup operations
- priority queing of backup operations to reduce run-time load level
- top level backup of apache path
- multi-stage Bind DNS backup
- multi-stage MySQL backup with MYI/ISM check, mysqldump of all databases to
individual .sql files, and master backup of mysql db path
- remote transfer of backup data via FTP or SCP (SSH)
- incremented transfer mode to conserve disk space during backups
- and much more...

Before we move on just need to make clear, as usual, Itake no responsibility with the use of this guide or the sysbk software

Ok this is basic installation we will move onto the directadmin side in a moment :)

from root:

# mkdir sysbk
# cd sysbk
# wget http://www.rfxnetworks.com/downloads/sysbk-current.tar.gz
# tar -zxvf sysbk-current.tar.gz
# rm -f sysbk-current.tar.gz
# cd sysbk-*
# chmod 750 install.sh
# ./install.sh
# cd
# cd /usr/local/sysbk
# pico -w conf.sysbk

set what you want to backup and what you dont want to backup from the default options there, leave ensim and cpanel areas as '0' so they do not get used.

If you want mysq / dns / apache backups ensure you set them to 1 not 0 on their first option for sysbk to make the backups of them. You mus also ensure that CUSTOM_BK="0" is chnaged to CUSTOM_BK="1" so we can specify the files needed to be backed up for directadmin and your accounts

[ctrl] + [x] to save press [y] to confirm.

# cd mod
# pico -w custom.dirs

# add paths to any additional directorys you wish to include some directadmin use are:
/home
/usr/local/directadmin
/usr/local/frontpage
/var/spool/virtual
/var/spool/mail
/var/www
/var/log
/etc/virtual
[ctrl] + [x] to save press [y] to confirm.

# pico -w custom.files
# add paths to any files you wish to include some directadmin use are:
/etc/exim.conf
/etc/exim.pl
/etc/system_filter.exim
/etc/exim.crt
/etc/exim.key
/etc/proftpd.conf
/etc/proftpd.vhosts.conf
/etc/proftpd.passwd
/etc/hosts
/etc/resolv.conf
[ctrl] + [x] to save press [y] to confirm.

The paths are based on http://directadmin.com/paths.html if you feel the need to add any others or remove any feel free to suggest :)

Before you atempt to use it i suggest you read through /usr/local/sysbk/conf.sysbk to input your ftp / ssh details there to connect / make the backup.... without that it may be unsuccessful with connecting for obvious reasons :)

Finally, the excutable is located at:

/usr/local/sysbk/sysbk

usage /usr/local/sbin/sysbk [-s] [-q]

-s Standard run
-q Quiet run


Chris
 

ProWebUK

Verified User
Joined
Jun 9, 2003
Messages
2,326
Location
UK
Dont specify any external locations, and just change your path from /home/backup to an area opn your second HD (whever it is mounted)

As default (if you dont specify any ftp locations) all backups will be organised in the format:

/home/backup/<date>/*backup sections*

Chris
 

S2S-Robert

Verified User
Joined
Jun 24, 2003
Messages
415
Location
The Netherlands
Will this also include executables and if so, will the backup be capable of being restored on a different RH OS? (9 instead of 7.3)
 

ProWebUK

Verified User
Joined
Jun 9, 2003
Messages
2,326
Location
UK
S2S-Robert said:
Will this also include executables and if so, will the backup be capable of being restored on a different RH OS? (9 instead of 7.3)
It can include anything you can usually pack with tar basically!.... with default options such as httpd and mysql it backs up the binaries along with all the main files and configs for example

Chris
 

S2S-Robert

Verified User
Joined
Jun 24, 2003
Messages
415
Location
The Netherlands
ProWebUK said:
It can include anything you can usually pack with tar basically!.... with default options such as httpd and mysql it backs up the binaries along with all the main files and configs for example

Chris
And now for the second part of my question? :D
 

ProWebUK

Verified User
Joined
Jun 9, 2003
Messages
2,326
Location
UK
Well..... anything that you could usually take from 7.3 and place on 9 will work...... if something is compiled specifcally for X then it may not work on another OS.

The upgrade software itself has no effect on whether the file you restore is suitable for whatever system you restore on.

Chris
 

netswitch

Verified User
Joined
Dec 15, 2003
Messages
175
Location
Belgium
don't we have to add
/var/named
in the custom.dirs file in order to backup the zone configuration ?


also somebody aldready tested a restart from scrath with this backup ?
 

bjseiler

Verified User
Joined
Jun 19, 2003
Messages
197
I am trying to run this on freebsd and I am getting this error. When I run ./sysbk -s

[: 0: unexpected operator
Archiving /home: [: custom/: unexpected operator
-en \033[62G
[ -en \033[1;32m
$COMPLETED-en \033[0;39m


Any ideas?
 

ProWebUK

Verified User
Joined
Jun 9, 2003
Messages
2,326
Location
UK
netswitch said:
don't we have to add
/var/named
in the custom.dirs file in order to backup the zone configuration ?


Nope, just ensure you enable DNS backup;

BIND_BK="0"

to:

BIND_BK="1"

It then backs up your whole /var/named directory (all zone files)aswell as your bind configuration file (/etc/named.conf)

I also advise you to enable all options apart from ensim and cpanel specialsed backup options :)

Regarding the restore, it basically just packs and compresses the files then stores them where you specify. locally or externally.. restore procedure should simply be untar the files....... I advise you to play around with some backups and the saved structure if you are unsure about anything.

Chris

Chris
 

ProWebUK

Verified User
Joined
Jun 9, 2003
Messages
2,326
Location
UK
bjseiler said:
I am trying to run this on freebsd and I am getting this error. When I run ./sysbk -s

[: 0: unexpected operator
Archiving /home: [: custom/: unexpected operator
-en \033[62G
[ -en \033[1;32m
$COMPLETED-en \033[0;39m


Any ideas?
Not sure if it works with FBSD. nothing noted on its website regarding it either.... unable to help when it comes to FBSD and 3rd party software (especially).

Sorry,
Chris
 

bjseiler

Verified User
Joined
Jun 19, 2003
Messages
197
Just so I am clear, when you run

./sysbk -s

you don't get any output that looks like what I posted?
 

ProWebUK

Verified User
Joined
Jun 9, 2003
Messages
2,326
Location
UK
bjseiler said:
Just so I am clear, when you run

./sysbk -s

you don't get any output that looks like what I posted?
Performing sanity checks: [ COMPLETED ]
Checking load average: [ COMPLETED ]
Checking free disk space: [ COMPLETED ]
Performing Apache backup: [ COMPLETED ]
Performing cleanup operations: [ COMPLETED ]


Is basically what you should get, the option to get no output would be quiet run (./sysbk -q)

Deepending what options you select the output above will vary, the example is for a backup of apache only... no custom no dns etc

Chris
 

ProWebUK

Verified User
Joined
Jun 9, 2003
Messages
2,326
Location
UK
prophecy said:
How about restoring all that now? Or is that a whole other ballgame?
It may sound difficult, however it's actually very easy..... move all of the tar.gz backups to your root directory (/root/) then simply unpack them - tar -zxvf *.tar.gz

Im fairly sure the backup includes symlinks - although it certainly holds the privileges :)

(Also remember to check the md5sums on your backups :) )

Chris
 

ProWebUK

Verified User
Joined
Jun 9, 2003
Messages
2,326
Location
UK
Its /var/spool/mail and its already under the custom directories :)

Chris
 

prophecy

Verified User
Joined
Jul 8, 2003
Messages
205
Ok, just went through this process today, and it's now 7:30 am and finally finishing up.

The backup process went smooth and that sysbk is very cool.

Restoring:

I basically, unpacked everything and copied each thing that was unpacked to the new OS build (RH 9). This worked great for everything, but email because permsissions were MESSED!

Issues

Had to remake all user accounts in RH using useradd.

Had to:
chmod -R diradmin.diradmin * in /usr/local/directadmin/data/users/ to dir

chown apache.apache * in /var/www/html/squirrelmail-1.4.2/data

chown admin.admin * in /home/admin/mail

make sure in /var/mail the owner is the username.mail

in /var/spool/virtual, the main user that created the accounts should own the files and dirs and mail should be the group (chown USER.mail)

I lost track of what permissions went where so this may not be right, but the email permissions should be the following thanks to John for this:


drwxrwxrwt 33 mail mail 1024 Jan 19 11:58 /var/spool/virtual

drwxrwx--- 2 username mail 1024 Jan 3 15:34 /var/spool/virtual/domain.com

-rw-rw---- 1 username mail 2010 Jan 20 12:11 /var/spool/virtual/domain.com/char
drwxr-xr-x 38 mail mail 2048 Jan 25 12:02 /etc/virtual

drwx--x--x 4 mail mail 1024 Jan 25 12:02 /etc/virtual/domain.com

/etc/virtual/domain.com/
-rw------- 1 mail mail 171 Jan 20 12:04 aliases
-rw------- 1 mail mail 30 Dec 31 14:55 autoresponder.conf
-rw------- 1 mail mail 2107 Dec 31 14:55 filter
-rw------- 1 mail mail 407 Dec 31 14:55 filter.conf
drwxr-x--x 5 majordom daemon 1024 Jan 23 20:31 majordomo
-rw------- 1 mail mail 57 Dec 31 14:55 passwd
-rw------- 1 mail mail 35 Dec 31 14:55 quota
drwx------ 2 mail mail 1024 Jan 4 14:05 reply
-rw------- 1 mail mail 119 Jan 4 14:03 vacation.conf
How could this have beens smoother?

I got to thinking how things coudl have been smoother and I think that if the users were made before unpacking, then the permissions may have worked out?? No idea, any linux guru know? And if that's the case, the order should have been:
  1. Backup from old machine using this guide and sysbk
  2. Create all users from old machine using useradd and appropriate groups if required.
  3. Unpack all backups into appropriate locations
    [/list=1]

    And that might have been better, I unpacked first and then created users and have been fixing permissions for the past day.
 

ProWebUK

Verified User
Joined
Jun 9, 2003
Messages
2,326
Location
UK
prophecy said:
I got to thinking how things coudl have been smoother and I think that if the users were made before unpacking, then the permissions may have worked out?? No idea, any linux guru know? And if that's the case, the order should have been:
Yes, if a user doesn't exist you shouldnt be able to give something ownerships of that user (since it doesnt exist!)

/etc/passwd and /etc/group may be an idea....... I will look into backing up full users.

Thanks for sharing the information :)

Chris
 
Top