SOLVED How to transfer tool via whmapi1 but to disable Live Transfer

Inna

Well-Known Member
Mar 10, 2018
51
9
58
Iran
cPanel Access Level
Root Administrator
Twitter
Hello,

As per in these docs: Transfer Tool | cPanel & WHM Documentation and Guide to Transfer and Restore API Functions - Create the Transfer Session and Create remote server transfer session, I see I can create remote transfer session, but these are my questions or issues that I didn't find in the docs:

1. How to let WHM use my ssh keys to create session? I added the keys, and `ssh -p2222 root@dest` logs in find.
2. How to inform WHM which users I want to transfer from `dest` to `local`? I want to transfer user `userA` from `dest` to `local`.
3. How to disable the Live Transfer to that the IP and nameservers in the DNS Zone file won't change?
4. How to inform WHM to overwrite the existing account? I mean I want to overwrite whenever I run the `whmapi` with no prompt.

Thanks
in advance
 
Last edited by a moderator:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
17,470
2,843
363
cPanel Access Level
Root Administrator
Hey there!

1 - There are details about using an SSH key on this page: Create remote server transfer session as root user
2 - Details on setting up the transfer are here: Guide to Transfer and Restore API Functions - Queue the Transfer Item
3 - Disabling the transfer can be found here: Guide to Transfer and Restore API Functions - Plan the Transfer Session
4 - This would be the "force" flag from the same option in the link in #2

I will say, the Transfer APIs do require a lot of initial setup, and aren't always intuitive. You'll need to use each step from the attached image in order to successfully perform a transfer:

Screenshot 2023-08-29 at 10-48-47 Guide to Transfer and Restore API Functions - Queue the Tran...png
 
  • Like
Reactions: Inna

Inna

Well-Known Member
Mar 10, 2018
51
9
58
Iran
cPanel Access Level
Root Administrator
Twitter
Hello,

This is my bash script:
Code:
# create session and store in a variable
session_id="$(/usr/sbin/whmapi1 --output=jsonpretty create_remote_root_transfer_session host='my.fqdn.com' user='root' port=2200 sshkey_name=id_ecdsa | awk '/"transfer_session_id" : / {print $3}' | sed -e 's|"||g' -e 's|,||g')"

# send these parameters to queue
/usr/sbin/whmapi1 enqueue_transfer_item \
    module=AccountRemoteRoot \
    user=myuser \
    localuser=myuser \
    force=1 \
    replaceip='basic' \
    skipaccount=1 \
    overwrite_sameowner_dbs=1 \
    overwrite_sameowner_dbusers=1 \
    transfer_session_id="$session_id"

# start transfer
/usr/sbin/whmapi1 start_transfer_session transfer_session_id="$session_id"
But after I run it to restore, I have the following warnings which creates new databases:
Code:
The system has restored the MySQL database "myuser_db" as "myuser_db2".
If I run again (in fact I tested it several times), I see this:
Code:
The system has restored the MySQL database "myuser_db" as "myuser_db3".
Can you please help me
how to overwrite the database?
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
17,470
2,843
363
cPanel Access Level
Root Administrator
Thanks for confirming that. Can you also confirm that you are not using the restricted mode options?

There is also an "overwrite_all_dbusers" flag as well that could be worth trying. From what I am seeing, you are doing everything correctly with your code.
 
  • Like
Reactions: Inna

Inna

Well-Known Member
Mar 10, 2018
51
9
58
Iran
cPanel Access Level
Root Administrator
Twitter
Thanks, I see in the docs:
I don't use unrestricted_restore. Is the default value of it set to 1? I can use it explicitly like this if that is the correct way:
Code:
unrestricted_restore=1
Regarding overwrite_all_dbusers, I don't see this option in the given docs, but I can only see that in the response in this docs.
Is the value an integer?
I mean should I use like this?
Code:
overwrite_all_dbusers=1
 

cPanelThomas

Developer
Feb 16, 2023
38
29
93
cPanel
cPanel Access Level
Root Administrator
RE overwrite_all_dbusers not showing up as an argument in the other API docs, that's somewhat of an oversight in my opinion. Basically, the schema modules there define the arguments you can pass into enqueue_transfer_item which correspond to the given module. Not really sure how to best relay that in docs however.
 
  • Like
Reactions: Inna

Inna

Well-Known Member
Mar 10, 2018
51
9
58
Iran
cPanel Access Level
Root Administrator
Twitter
These are the logs of my last transfer (last night in fact):

MysqlRemoteNotes
MysqlRemoteNotes
Mysql
Preparing MySQL restore …
Databases owned by “myuser” will be overwritten on conflict.
The system will restore the database “myuser_db” as “myuser_db4” because another cPanel user owns “myuser_db”.
Restoring MySQL databases
Restoring the database “myuser_db” as “myuser_db4” …
The system has created a new database named “myuser_db4”.
Granting “myuser” access to “myuser_db4” with temporary password …
Spawning restoration subprocess for “myuser_db4” …
The remote MySQL dump ended successfully.
Transfer complete. Awaiting subprocess completion …
Connecting to SQL server (/var/lib/mysql/mysql.sock) as “myuser” in order to restore “myuser_db4” …
Disabling InnoDB strict mode for database restore for “myuser_db4” …
Restoring database data for “myuser_db4” …
Processing SQL statements …
The database restoration subprocess for “myuser_db4” has ended.
The system has restored the contents of the database “myuser_db4”.
Restoring MySQL database mappings
Restoring MySQL privileges
Database users owned by “myuser” will be overwritten on conflict.
Restoring MySQL grants
Restoring MySQL access hosts
Storing MySQL Grants
Mysql
Just to make it clear:

In the server account is restored, I first created a new account called "myuser". Then I ran my script to live transfer from the source.
Is that correct what I did? I suspect this may raise the issue.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
17,470
2,843
363
cPanel Access Level
Root Administrator
I wasn't able to reproduce this on the test machines I built, as the database and the user were properly overwritten when using your script.

Could you submit a ticket to our team so we could do some additional testing with your environment?
 
  • Like
Reactions: Inna

Inna

Well-Known Member
Mar 10, 2018
51
9
58
Iran
cPanel Access Level
Root Administrator
Twitter
Thanks.
I'm trying to obtain trial license but I'm not sure why I cannot.
I reset my password in but I cannot logon with the new password in account.cpanel.net.

Can I send you the IPs in your private message to activate the trial?