mirror of
https://github.com/unraid/webgui.git
synced 2026-05-03 08:19:27 -05:00
Added "USB backup" function
This commit is contained in:
@@ -31,7 +31,7 @@ function backup() {
|
||||
$.post('/webGui/include/Download.php',{cmd:'backup'},function(zip) {
|
||||
if (zip) {
|
||||
location = '/'+zip;
|
||||
setTimeout(function(){cleanUp(zip);},4000);
|
||||
setTimeout(function(){cleanUp(zip);},6000);
|
||||
} else {
|
||||
$('input[value="Creating USB backup..."]').val('USB backup');
|
||||
$('#pleaseWait').hide('slow');
|
||||
@@ -65,4 +65,5 @@ Flash GUID:
|
||||
|
||||
: <input type="button" value="USB backup" onclick="backup()"><input type="button" value="Done" onclick="done()">
|
||||
|
||||
<br><div id="pleaseWait" style="display:none;font-weight:bold;color:red;text-align:center">Please wait... creating USB backup zip file (this may take several minutes)</div>
|
||||
<br><div id="pleaseWait" style="display:none;text-align:center"><span class="red-text strong">Please wait... creating USB backup zip file (this may take several minutes)</span>
|
||||
<br><br><span class="small">Do not leave this page until backup operation is finished</span></div>
|
||||
|
||||
@@ -14,19 +14,22 @@
|
||||
<?
|
||||
$docroot = $docroot ?: $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
$var = file_exists('/var/local/emhttp/var.ini') ? parse_ini_file('/var/local/emhttp/var.ini') : [];
|
||||
$out = ['previous','syslinux'];
|
||||
$dir = ['system','appdata','isos'];
|
||||
$out = ['prev','previous','syslinux'];
|
||||
|
||||
$server = isset($var['NAME']) ? str_replace(' ','_',strtolower($var['NAME'])) : 'tower';
|
||||
$mydate = date('Ymd-Hi');
|
||||
$backup = "$server-usb-backup-$mydate.zip";
|
||||
|
||||
list($used,$free) = explode(',',exec("df /boot|awk 'END{print $3,$4}'"));
|
||||
$usb = $free > $used;
|
||||
foreach (glob('/mnt/user/*',GLOB_ONLYDIR) as $share) {
|
||||
$free = exec("df $share|awk 'END{print $4}'");
|
||||
if ($free > $used) {$zip = $share; break;}
|
||||
$used = exec("df /boot|awk 'END{print $3}'") * 1.5;
|
||||
$free = exec("df /|awk 'END{print $4}'");
|
||||
if ($free > $used) $zip = "/$backup"; else {
|
||||
foreach ($dir as $share) {
|
||||
if (!is_dir("/mnt/user/$share")) continue;
|
||||
$free = exec("df /mnt/user/$share|awk 'END{print $4}'");
|
||||
if ($free > $used) {$zip = "/mnt/user/$share/$backup"; break;}
|
||||
}
|
||||
}
|
||||
$zip = $zip ? "$zip/$backup" : ($usb ? "/boot/$backup" : "");
|
||||
if ($zip) {
|
||||
chdir("/boot");
|
||||
foreach (glob("*",GLOB_NOSORT+GLOB_ONLYDIR) as $folder) {
|
||||
|
||||
Reference in New Issue
Block a user