backup before terminate

cPanel, Industry leading hosting platform with world-class support.
Post Reply
ludolugo
Posts: 52
Joined: April 17th, 2020, 10:40 am

backup before terminate

Post by ludolugo »

Hi
is it possible to run a backup at the moment a cpanel account is terminated? maybe a hook or something to make a snapshot? this because sometimes an account is terminated and the backup is almost 24 hours old. this is to cover our back in case of a support mistake
Last edited by ludolugo on April 29th, 2021, 12:59 pm, edited 1 time in total.
JetAppsRichard
Staff Member
Staff Member
Posts: 97
Joined: January 1st, 2021, 12:51 am

Re: backup before suspension

Post by JetAppsRichard »

Hello ludolugo,

Thank you for reaching out through our forums! Once a cPanel account is terminated, JetBackup 5 has an onTerminateHook that will automatically tag the account as an "Orphan Account" within the JetBackup Interface. Once an account is tagged as an orphan, no backups can/will be generated for this account.

You are able to add custom hooks to WHM/cPanel for the Account::Remove event. I would suggest creating a pre-hook that will run a backup on demand for the account before terminating the account. You can use our jetbackup5api within the cPanel hook in order to create a backup on demand. You will need the following information to do so:

1. First you will need to know the name of the username of the account being terminated. This can be gathered in the hook action code when the script is run. Follow the cPanel guide for creating hooks here: https://documentation.cpanel.net/displa ... ized+Hooks
2. Once the account username is gathered, you can run the following command to get the Accounts Object Id from JetBackup 5.

Code: Select all

jetbackup5api -F listAccounts -D "filter=USERNAME"
3. After running this command you will be able to fetch the accounts _id from the response.
4. With the Accounts _id you can finally run the following command to create a backup on demand for that account.

Code: Select all

jetbackup5api -F createBackupOnDemand -D "account_id={_ID}"
Please note that Backup on Demand must be enabled in order for the API command to succeed. Please ensure that this is enabled in Settings -> Backup On Demand. For more information please visit our documentation for Backup on Demand

Additionally, if you believe this should be a feature within JetBackup I highly recommend opening a new Feature Request to gain votes. Our developers use the voting feature to gauge popularity for requests and the more votes a request has, the more likely it will be up for consideration.

If you have any more questions please let us know.
Best Regards,
Richard, JetApps Team
User avatar
elialum
Staff Member
Staff Member
Posts: 95
Joined: October 25th, 2015, 1:44 pm

Re: backup before suspension

Post by elialum »

Hi,

Maybe this will help also

http://blog.jetserver.net/jetbackup-bet ... then-sorry

:)

Thanks,
Eli.
ludolugo
Posts: 52
Joined: April 17th, 2020, 10:40 am

Re: backup before suspension

Post by ludolugo »

Thanks JetAppsRichard and elialum

All of our servers have jetbackup 4 and as i understand jetbackup 4 can not execute a manual snapshot or backup on demand over cli, am i correct? or at least i couldn`t find it.
JetAppsRichard
Staff Member
Staff Member
Posts: 97
Joined: January 1st, 2021, 12:51 am

Re: backup before suspension

Post by JetAppsRichard »

Hello ludolugo,

In order to manually execute a snapshot using JetBackup 4 API you would need to use the command `addQueueSnapshot` and pass it the username of the account. For example:

Code: Select all

jetapi backup -F addQueueSnapshot -D 'username=acct01'
You can more information about this command here: https://docs.jetbackup.com/manual/whm-a ... pshot.html

Please note that the result from this command will add the snapshot to the queue in which jetbackup 4 executes every minute via the cron. In order to execute the snapshot immediately you will need to gather the snapshot _id from the result of the above command:

Code: Select all

success: 1
message: The selected account have been added to the snapshots queue.
system:
  version: 4.0.25
  tier: STABLE
  type: cPanel
  drMode:
  agreement:
  licenseIssue:
data:
  _id: 6088aba5d6c44e3d00268822
  ...
Then run the following command with the gathered snapshot _id:

Code: Select all

/usr/bin/jetcli backup -vR snapshots -I {_id}
Please let us know if you require any further assistance.
Best Regards,
Richard, JetApps Team
ludolugo
Posts: 52
Joined: April 17th, 2020, 10:40 am

Re: backup before terminate

Post by ludolugo »

great, almost there...
as you said the queue snapshot executes every minute but if an account is terminated i guess it won`t work as the account doesn't exist anymore, what can i do in that case?
thanks
JetAppsRichard
Staff Member
Staff Member
Posts: 97
Joined: January 1st, 2021, 12:51 am

Re: backup before terminate

Post by JetAppsRichard »

Hello,

In this case, you would need to execute the snapshot immediately after it has been queued. As mentioned in my last response, the addQueueSnapshot command will return the SNAPSHOT ID that you could then use to run the snapshot immediately with the following command:

Code: Select all

/usr/bin/jetcli backup -vR snapshots -I {_id}
The above command should execute in the shell that is created when the hook is triggered and the hook should not complete until after the snapshot is complete. Please give this a try and let us know if we can assist further.
Best Regards,
Richard, JetApps Team
ludolugo
Posts: 52
Joined: April 17th, 2020, 10:40 am

Re: backup before terminate

Post by ludolugo »

excellent, i'll give it a try.

thanks for the patience
Post Reply