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
backup before terminate
backup before terminate
Last edited by ludolugo on April 29th, 2021, 12:59 pm, edited 1 time in total.
-
- Staff Member
- Posts: 97
- Joined: January 1st, 2021, 12:51 am
Re: backup before suspension
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.
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.
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.
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"
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}"
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
Richard, JetApps Team
Re: backup before suspension
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.
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.
-
- Staff Member
- Posts: 97
- Joined: January 1st, 2021, 12:51 am
Re: backup before suspension
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:
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:
Then run the following command with the gathered snapshot _id:
Please let us know if you require any further assistance.
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'
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
...
Code: Select all
/usr/bin/jetcli backup -vR snapshots -I {_id}
Best Regards,
Richard, JetApps Team
Richard, JetApps Team
Re: backup before terminate
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
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
-
- Staff Member
- Posts: 97
- Joined: January 1st, 2021, 12:51 am
Re: backup before terminate
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:
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.
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}
Best Regards,
Richard, JetApps Team
Richard, JetApps Team
Re: backup before terminate
excellent, i'll give it a try.
thanks for the patience
thanks for the patience