1

User backups queue


L
luki m

possibility to queue backups ordered in the DA panel by users and only run them overnight via cron or manuall

A

Activity Newest / Oldest

S

mutter

Yea, you're right. The PROCESS_INFO_FILE environment variable isn't included in the environment variables. You have to create this one on your own.

In the user_backup_pre.sh file, to fill the PROCESS_INFO_FILE variable use:

export PROCESS_INFO_FILE=$(/usr/sbin/lsof -n -p $$ | grep '/usr/local/directadmin/data.*task_queue_processes' | awk '{print $9}' | sed "s%level_tracker%process_info%g")

That will look up the file associated with the running process ID. Grep out the line that matches '/usr/local/directadmin/data.*task_queue_processes'. Read the 9th column. And replace level_tracker with process_info.

(This is on a CentOS 7 system... if your OS is different some of this may be different)

It is that file that contains the information that would need to be placed in /usr/local/directadmin/data/task.queue or /usr/local/directadmin/data/task.queue.cb to backup the account with datataskq.

Don't ask me how I figured all of this out. Probably some luck involved.

So, possible? Yes. Complicated? Yes, also.


  • L
S

mutter

You can kind of already do this.

You can manipulate user backups in the - /usr/local/directadmin/scripts/custom/user_backup_pre.sh - hook.

Add the user to your own queue (however you want to do that) and end the script with:

exit 1

so that it does not proceed with the backup.

In the custom queuing part, you need to take a look at the PROCESS_INFO_FILE environment variable passed to /usr/local/directadmin/scripts/custom/user_backup_pre.sh. Read that file, which will be a config file of key=value on each line. You basically need to replace the newlines with & symbols.

This single line would then be passed to /usr/local/directadmin/data/task.queue or /usr/local/directadmin/data/task.queue.cb when you want to do the actual backup, presumably in whatever script you have to run at designated time periods.

Then you would execute /usr/local/directadmin/dataskq or /usr/local/directadmin/dataskq --custombuild (depending on which task.queue file you used) to actually run the backup.


L

luki m

I tried this method before posting here, but with no results. Displaying env from user_backup_pre.sh only returns (docs.directadmin.com/developer/hooks/backup_restore.html#user-backup-pre-post-sh):
owner=.
LANG=en-US.utf8
INVOCATION_ID=a1ab109b74334ff08d0cd1dded9a46a6
PWD=/usr/local/directadmin
JOURNAL_STREAM=9:29350623
reseller=admin
file=/home/LOGIN/backups/backup-Nov-10-2022-2.tar.zst
username=LOGIN
SHLVL=2
LANGUAGE=en-US
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
_=/usr/bin/env

Displaying env from e.g. all_pre.sh returns the correct values, but only there.