Sk-DirectAdmin-Importer | Script to Restore DirectAdmin User Account In VestaCP

Section with additional software for Vesta
skamasle
Collaborator
Posts: 378
Joined: Mon Feb 29, 2016 6:36 pm

Sk-DirectAdmin-Importer | Script to Restore DirectAdmin User Account In VestaCP

Postby skamasle » Sun Feb 12, 2017 10:44 pm

Hi

Im working in new script to help people move to vestacp, now I do DirectAdmin importer ( similar to Cpanel Importer )

For now I need a lite help, I need to do some test more in this script whit diferent backups if some body can help and send some backupwhit out sensible data, just backups from user account whit some domains, subdominios, databases etc whit no real information will help a lot.

At this time script can do this:

-Restore full User level account.
-Restore domains and web site files.
-Restore databases, mysql user and passwords.
-Restore Mails accounts whit mail passwords.

What script cant do:
- Restore subdomains -> I not know how subdomains work in DA because I only have backups from DA whit domains, there is no subdomain options in my DA backups so, I Think script need some lines of code to fix this and I will add it when I get new backups whit more content.

-Crons, SSL and some orther features will be added later.

First realease ready!


En español -> https://www.skamasle.com/migrar-cuenta- ... a-vestacp/
Last edited by skamasle on Wed Feb 15, 2017 7:25 pm, edited 1 time in total.

skamasle
Collaborator
Posts: 378
Joined: Mon Feb 29, 2016 6:36 pm

Re: Sk-DirectAdmin-Importer | Script to Restore DirectAdmin User Account In VestaCP

Postby skamasle » Wed Feb 15, 2017 7:23 pm

First alpha is here if some body whant test it

Image

Runt at your own risk

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. http://www.gnu.org/licenses/


Code: Select all

cd /root/

wget mirror.skamasle.com/vestacp/skdaimporter/sk_da_importer.sh

bash sk_da_importer.sh da-user-backup.tar.gz


This is alpha, report any problem here.

skamasle
Collaborator
Posts: 378
Joined: Mon Feb 29, 2016 6:36 pm

Re: Sk-DirectAdmin-Importer | Script to Restore DirectAdmin User Account In VestaCP

Postby skamasle » Sun Mar 12, 2017 8:07 pm

This was updated, if importer not working ( not restore domains )

You can set sk_get_dom=2 to try get domain list from domain dir directly

Changes in

https://github.com/Skamasle/sk_da_importer

edatamax
Posts: 1
Joined: Sun Mar 12, 2017 4:52 am

Re: Sk-DirectAdmin-Importer | Script to Restore DirectAdmin User Account In VestaCP

Postby edatamax » Tue Mar 14, 2017 3:00 pm

Great job!
This script works as described.
Everything gets restored.
I changed sk_get_dom to 2.
Keep up the good work!
Thanks

skamasle
Collaborator
Posts: 378
Joined: Mon Feb 29, 2016 6:36 pm

Re: Sk-DirectAdmin-Importer | Script to Restore DirectAdmin User Account In VestaCP

Postby skamasle » Thu Apr 13, 2017 6:05 pm

There is a issue with centos 6 because use old bash, if some body get this:

Code: Select all

Substring expresion -5: substring expression < 0


There is a fix in github, remplacing on line 122:

Code: Select all

userdb=${sk_da_db_u:: -5}


for

Code: Select all

userdb=$(echo $sk_da_db_u |sed "s/.conf//")


Working fine in bash 4.4 and will fail in bash 4.2 and older maybe in bash 4.3.. ( not tested )

2infinity
Posts: 1
Joined: Mon May 01, 2017 7:01 pm

Re: Sk-DirectAdmin-Importer | Script to Restore DirectAdmin User Account In VestaCP

Postby 2infinity » Mon Jun 05, 2017 5:04 pm

Hi,

I've been struggling with this script for some time now as the migration didn't complete.
I've looked in de script and found that the imap function is looking for accounts in the backup folder.
After some searching I found an easy solution.
In your directadmin.conf add
direct_imap_backup=0

# cd /usr/local/directadmin/conf/
# nano directadmin.conf

Save config ( ctrl X -> Y ) and restart directadmin
# service directadmin restart

Create your user backups which will include the imap accounts in the backup folder of the tar.
Now the importer works fine for normal user accounts.

skamasle
Collaborator
Posts: 378
Joined: Mon Feb 29, 2016 6:36 pm

Re: Sk-DirectAdmin-Importer | Script to Restore DirectAdmin User Account In VestaCP

Postby skamasle » Tue Jun 06, 2017 7:32 pm

2infinity wrote:Hi,

I've been struggling with this script for some time now as the migration didn't complete.
I've looked in de script and found that the imap function is looking for accounts in the backup folder.
After some searching I found an easy solution.
In your directadmin.conf add
direct_imap_backup=0

# cd /usr/local/directadmin/conf/
# nano directadmin.conf

Save config ( ctrl X -> Y ) and restart directadmin
# service directadmin restart

Create your user backups which will include the imap accounts in the backup folder of the tar.
Now the importer works fine for normal user accounts.



Hi thanks for advice

Directadmin change some options in in their sistem and have a lot of config options, this script will fail in some cases

If you have full backup type not supported by this script you can sendme it and when I get some time I will add support for it.

bdacus01
Posts: 5
Joined: Mon Aug 28, 2017 6:21 pm

Re: Sk-DirectAdmin-Importer | Script to Restore DirectAdmin User Account In VestaCP

Postby bdacus01 » Mon Aug 28, 2017 7:21 pm

From DA website. direct_imap_backup is feature works as below.

New option, disabled by default:
direct_imap_backup=0

but can be enabled by adding:
direct_imap_backup=1

into your directadmin.conf.

When enabled, this feature will store the "imap" folder directly into the tar.gz backup file, saving the need to first copy all emails to an assembly area.
This should greatly speed up the backup process.

Previously, the /home/user/imap/domain.com/* data was stored in:
backup/domain.com/email/data/imap/*

but when this feature is enabled, a file:
backup/domain.com/email/data/imap/.direct_imap_backup

will be created, telling DA to extract:
imap/*

to /home/user/imap/*

For security reasons, the extraction is done as user:user, and not user:mail.
Then a secure recursive chown is done whereby it temporarily renames each file to a random value, checks for hardlinks, and checks for user:user ownership.
If all passes, it's then lchown, and renamed back.
The reason for the excessive checks is anytime a recrsive chown is done on files that can be controlled by a User, there is a risk of hardlinks being added, where DA might end up doing a chown on /etc/shadow, for example,
but there can also be a race condition where the client creates the hardlink after the check in DA is done, but before the chown happens, hence we need to rename the file to prevent that, as the client won't be able to predict the filename.

Currently, only /home/user/imap is done this way.
The /home/user/Maildir folder is still stored in the home.tar.gz (for now)

bdacus01
Posts: 5
Joined: Mon Aug 28, 2017 6:21 pm

Re: Sk-DirectAdmin-Importer | Script to Restore DirectAdmin User Account In VestaCP

Postby bdacus01 » Mon Aug 28, 2017 7:23 pm

I have a DA backup if you tell me how you want it I will send you one.


Return to “3rd Party Software”



Who is online

Users browsing this forum: No registered users and 2 guests