When router hard power off while saving , all quotas removed.
I need to make Backup for "/usr/data/quotas" directory to other directory before saving Quotas changes.
I added this line but it not worked for me, please any one can help me to make this right.
cp /usr/data/quotas /usr/data/quotas_backup_m
Code: Select all
function saveChanges(){
cp /usr/data/quotas /usr/data/quotas_backup_m
setControlsEnabled(!1,!0);var e=[],t=uciOriginal.getAllSectionsOfType(pkg,"quota");while(t.length>0){var n=t.shift();uciOriginal.removeSection(pkg,n),e.push("uci del "+pkg+"."+n)}e.push("uci commit");var r=uci.getAllSectionsOfType(pkg,"quota"),i="\nuci del gargoyle.status.quotause ; uci commit ;\n",s=[];while(r.length>0){var n=r.shift(),o=uci.get(pkg,n,"id");s[o]=n,changedIds[o]==1&&uci.set(pkg,n,"ignore_backup_at_next_restore","1")}var u=document.getElementById("quota_table_container").firstChild,a=getTableDataArray(u,!0,!1),f=0;for(f=0;f<a.length;f++){var l=a[f][rowCheckIndex],c=s[l.id];c!=null&&(uci.set(pkg,c,"enabled",l.checked?"1":"0"),l.checked&&(i='\nuci set gargoyle.status.quotause="225" ; uci commit ;\n'))}var h=[];h.push("sh /usr/lib/gargoyle/restart_firewall.sh"),h.push('if [ -d "/usr/data/quotas/" ] ; then rm -rf /usr/data/quotas/* ; fi ;'),h.push("backup_quotas");var p=e.join("\n")+"\n"+uci.getScriptCommands(uciOriginal)+"\n"+i+"\n"+h.join("\n"),d=getParameterDefinition("commands",p)+"&"+getParameterDefinition("hash",document.cookie.replace(/^.*hash=/,"").replace(/[\t ;]+.*$/,"")),v=function(e){e.readyState==4&&(setControlsEnabled(!0),window.location.href=window.location.href)};runAjax("POST","utility/run_commands.sh",d,v)
}