Backup Monitor (API) (SKINS)

Version 1.441

Feature
Finished

Dec 10, 2013: Bug found if you use track_task_queue_processes=2: http://www.directadmin.com/features.php?id=1534 Fixed in the pre-release binaries, or 1.44.2 or greater. ------------------- Thread: http://forum.directadmin.com/showthread.php?t=47417 Ability to track backup progress (and possibly any task in the dataskq or "directadmin", depending how this goes) You must reload your CMD_ADMIN_BACKUP (Admin Backup/Transfer) page after the backup has started to have the table show up. We may change this to have an ajax reload in the future, but for now, if you're waiting to see a backup, just hit F5 a few times. Default internal variable: track_task_queue_processes=1 which gives a process overview of who's being backed up, how many Users there are, and what part of the backup progress is being made for each User. I'll add a progress bar that moves long slowly using ajax for an accurate measure. You can also set this in your directadmin.conf: track_task_queue_processes=2 to get a much more detailed track, in addition to the above information. With 2, the dataskq will dump any tracked process location to a log file, which will scroll in DA as it goes. Include API-ability. =================================== SKINS admin/admin_backup_monitor.html files_admin.conf: CMD_ADMIN_BACKUP_MONITOR=admin/admin_backup_monitor.html =================================== JSON - updated August 2, 2018 If you call: CMD_ADMIN_BACKUP?json=yes you'll get the usual admin backup page, but if a backup is running, you'll also get a JSON entry: "current_backups": { "0": { "pid": "555", "id": "", "start": { "dayofmonth": "", "dayofweek": "", "hour": "", "minute": "", "month": "" }, "who": { "select": [ "cronuser" ], "who": "selected" }, "where": "<span class='green_lock'>&#128274;</span> /home/admin/admin_backups2", "progress": "0.00%", "details": "CMD_ADMIN_BACKUP?action=monitor&pid=555" }, "info": { "columns": { "pid": "1", "id": "2", "start": "3", "who": "4", "where": "5", "progress": "6", "details": "7" }, "current_page": "1", "ipp": "99999", "rows": "1", "total_pages": "1" } }, ------------ With that information, you can then use action=monitor, if you want to just view that process: CMD_ADMIN_BACKUP?action=monitor&pid=555&json=yes { "backup_info": { "0": { "pid": "555", "id": "", "owner": "admin", "start": "1533247621", "who": { "select": [ "cronuser" ], "who": "selected" }, "where": "<span class='green_lock'>&#128274;</span> /home/admin/admin_backups2" }, "info": { "columns": { "pid": "1", "id": "2", "owner": "3", "start": "4", "who": "5", "where": "6" }, "current_page": "1", "ipp": "50", "rows": "1", "total_pages": "1" } }, "track_task_queue_processes": "2" } ------------ And one lever further if you want the play-by-play: CMD_ADMIN_BACKUP?action=monitor&pid=555&get=tracking_data where it slowly generates JS code, which you'd have your side run (or just parse/display).. sort of a hacky way about doing it, but works for the skin (isn't json-ified, as it's js-ified) Note that the track_task_queue_processes=2 will give much much more output than the 1 value, where 1 is set by default, so this is more than usual. As mentioned, DA will trickle this data slowly, as it happens. Related: https://www.directadmin.com/features.php?id=1509 You can find the client-side JS in enhanced: admin/admin_backup_monitor.html sample streamed get=tracking_data output: document.getElementById('dynamic_text').innerHTML='Backup User cronuser'; document.getElementById('dynamic_details').innerHTML='user&#95;backup&#95;pre.sh'; add_process_info('User&#40;&#39;admin&#39;&#41;&#58;&#58;readFile&#40;&#41; &#58; uuf'); add_process_info('getlock&#40;./data/users/admin/user.usage, &#39;ConfigFile&#58;&#58;readFile&#39;&#41; &#58; start'); add_process_info('getlock&#40;./data/users/admin/user.usage, &#39;ConfigFile&#58;&#58;readFile&#39;&#41; &#58; finished'); add_process_info('User&#40;&#39;admin&#39;&#41;&#58;&#58;readFile&#40;&#41; &#58; dlf'); add_process_info('getlock&#40;./data/users/admin/domains.list, &#39;ListFile&#58;&#58;readFile&#39;&#41; &#58; start'); add_process_info('getlock&#40;./data/users/admin/domains.list, &#39;ListFile&#58;&#58;readFile&#39;&#41; &#58; finished'); add_process_info('User&#40;&#39;admin&#39;&#41;&#58;&#58;readFile&#40;&#41; &#58; ucf'); add_process_info('getlock&#40;./data/users/admin/user.conf, &#39;ConfigFile&#58;&#58;readFile&#39;&#41; &#58; start'); add_process_info('getlock&#40;./data/users/admin/user.conf, &#39;ConfigFile&#58;&#58;readFile&#39;&#41; &#58; finished'); add_process_info('User&#40;&#39;admin&#39;&#41;&#58;&#58;readFile&#40;&#41; &#58; finished'); add_process_info('getlock&#40;./data/users/admin/reseller.usage, &#39;ConfigFile&#58;&#58;readFile&#39;&#41; &#58; start'); add_process_info('getlock&#40;./data/users/admin/reseller.usage, &#39;ConfigFile&#58;&#58;readFile&#39;&#41; &#58; finished'); add_process_info('getlock&#40;./data/users/admin/users.list, &#39;ListFile&#58;&#58;readFile&#39;&#41; &#58; start'); add_process_info('getlock&#40;./data/users/admin/users.list, &#39;ListFile&#58;&#58;readFile&#39;&#41; &#58; finished'); add_process_info('getlock&#40;./data/users/admin/reseller.conf, &#39;ConfigFile&#58;&#58;readFile&#39;&#41; &#58; start'); add_process_info('getlock&#40;./data/users/admin/reseller.conf, &#39;ConfigFile&#58;&#58;readFile&#39;&#41; &#58; finished'); add_process_info('getlock&#40;./data/users/admin/reseller.allocation, &#39;ConfigFile&#58;&#58;readFile&#39;&#41; &#58; start'); add_process_info('getlock&#40;./data/users/admin/reseller.allocation, &#39;ConfigFile&#58;&#58;readFile&#39;&#41; &#58; finished'); add_process_info('getlock&#40;./data/admin/admin.conf, &#39;ConfigFile&#58;&#58;readFile&#39;&#41; &#58; start'); add_process_info('getlock&#40;./data/admin/admin.conf, &#39;ConfigFile&#58;&#58;readFile&#39;&#41; &#58; finished'); add_process_info('getlock&#40;./data/admin/admin.usage, &#39;ConfigFile&#58;&#58;readFile&#39;&#41; &#58; start'); add_process_info('getlock&#40;./data/admin/admin.usage, &#39;ConfigFile&#58;&#58;readFile&#39;&#41; &#58; finished'); add_process_info('getlock&#40;./data/admin/reseller.list, &#39;ListFile&#58;&#58;readFile&#39;&#41; &#58; start'); add_process_info('getlock&#40;./data/admin/reseller.list, &#39;ListFile&#58;&#58;readFile&#39;&#41; &#58; finished'); add_process_info('getlock&#40;./data/admin/admin.list, &#39;ListFile&#58;&#58;readFile&#39;&#41; &#58; start'); add_process_info('getlock&#40;./data/admin/admin.list, &#39;ListFile&#58;&#58;readFile&#39;&#41; &#58; finished'); add_process_info('getlock&#40;./data/admin/admin.allocation, &#39;ConfigFile&#58;&#58;readFile&#39;&#41; &#58; start'); add_process_info('getlock&#40;./data/admin/admin.allocation, &#39;ConfigFile&#58;&#58;readFile&#39;&#41; &#58; finished'); add_process_info('getDirFilesAndDirs&#40;./data/users, &#42;tlf, &#42;tdlf, &#40;null&#41;&#41;'); add_process_info('getDirFilesAndDirs&#40;./data/users, &#42;tlf, &#42;tdlf, &#40;null&#41;&#41; &#58; done'); add_process_info('getlock&#40;./data/users/cronuser/user.conf, &#39;ConfigFile&#58;&#58;readFile&#39;&#41; &#58; start'); add_process_info('getlock&#40;./data/users/cronuser/user.conf, &#39;ConfigFile&#58;&#58;readFile&#39;&#41; &#58; finished'); add_process_info('User&#40;&#39;cronuser&#39;&#41;&#58;&#58;readFile&#40;&#41; &#58; uuf'); add_process_info('User&#40;&#39;cronuser&#39;&#41;&#58;&#58;readFile&#40;&#41; &#58; dlf'); add_process_info('User&#40;&#39;cronuser&#39;&#41;&#58;&#58;readFile&#40;&#41; &#58; ucf'); add_process_info('User&#40;&#39;cronuser&#39;&#41;&#58;&#58;readFile&#40;&#41; &#58; finished'); add_process_info('User&#58;&#58;setQuota&#40;&#48;&#41; &#58; cronuser'); add_process_info('getHomeDir &#58; cronuser'); add_process_info('getHomeDir &#58; cronuser &#58; done'); add_process_info('custom script&#58; /usr/local/directadmin/scripts/custom/user&#95;backup&#95;pre.sh &#58; &#39;file&#61;/home/admin/admin&#95;backups&#50;/user.admin.cronuser.tar.gz&#38;reseller&#61;admin&#38;username&#61;cronuser&#39;'); set_percent('0.00'); set_percent('0.00'); set_percent('0.00'); set_percent('0.00'); set_percent('0.00'); set_percent('0.00'); set_percent('0.00'); set_percent('0.00'); set_percent('0.00'); set_percent('0.00'); set_percent('0.00'); set_percent('0.00'); set_percent('0.00'); set_percent('0.00'); set_percent('0.00'); set_percent('100'); document.getElementById('dynamic_text').innerHTML='Backup Complete'; document.getElementById('dynamic_details').innerHTML=''; Note the menthod used to geneated this backup output was to add a very long sleep in the user_backup_pre.sh, hence it's sitting at 0% for a long time. It then jumps to the end, as the User was small. If you were to load the page after the backup was done: CMD_ADMIN_BACKUP?action=monitor&pid=555&json=yes&get=tracking_data you'll get this output, which can be used to determine if it's done.. but you must know the PID first. document.getElementById('dynamic_text').innerHTML='Cannot find that pid number. Backup may already be finished.';

Interested to try DirectAdmin? Get a 30-day Free Trial!