add date and time to logged rsync errors
This commit is contained in:
parent
4ce99e89a4
commit
807c8351c1
|
@ -4,7 +4,7 @@ EZ-Bkup is released under the General Public License 3.0.
|
|||
See COPYING or <https://www.gnu.org/licenses/> for details.]#
|
||||
|
||||
import owlkettle
|
||||
import osproc, os, logging, sequtils
|
||||
import osproc, os, logging, sequtils, times
|
||||
import edit_routine_dialog
|
||||
import "../models/routine", "../shared"
|
||||
|
||||
|
@ -27,6 +27,8 @@ proc rsyncThread(list: RoutineListState) {.thread.} =
|
|||
createDir(appPath)
|
||||
|
||||
var logger = newFileLogger(appPath & "/errors.log")
|
||||
let dt = now()
|
||||
let nowDT = dt.format("M-d-YYYY h:mm:ss tt")
|
||||
|
||||
#i'm not sure if using threadvar here is needed, but doing it just in case. :)
|
||||
var rsyncRunCmd {.threadvar.}: string
|
||||
|
@ -57,10 +59,10 @@ proc rsyncThread(list: RoutineListState) {.thread.} =
|
|||
rsyncRunCmd = "pkexec rsync -aq " & "'" & source & "'" & " " & "'" & destination & "'"
|
||||
rsyncRun = execCmdEx(rsyncRunCmd)
|
||||
if rsyncRun.exitCode != 0:
|
||||
rsyncErrors.add("EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to back up " & source & " to " & destination)
|
||||
rsyncErrors.add("(" & nowDT & ")" & "EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to back up " & source & " to " & destination)
|
||||
#handle non-perms related error.
|
||||
else:
|
||||
rsyncErrors.add("EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to back up " & source & " to " & destination)
|
||||
rsyncErrors.add("(" & nowDT & ")" & "EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to back up " & source & " to " & destination)
|
||||
#explicitly check that sources were copied to destinations.
|
||||
#just using file names, mod times, and size (same as bkup run itself).
|
||||
#quote sources and destinations to handle possible spaces.
|
||||
|
@ -74,10 +76,10 @@ proc rsyncThread(list: RoutineListState) {.thread.} =
|
|||
rsyncCheckCmd = "pkexec rsync -rn " & "'" & source & "'" & " " & "'" & destination & "'"
|
||||
rsyncCheckRun = execCmdEx(rsyncCheckCmd)
|
||||
if rsyncCheckRun.exitCode != 0:
|
||||
rsyncErrors.add("EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to verify that " & source & " got backed up to " & destination)
|
||||
rsyncErrors.add("(" & nowDT & ")" & "EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to verify that " & source & " got backed up to " & destination)
|
||||
#handle non-perms related error.
|
||||
else:
|
||||
rsyncErrors.add("EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to verify that " & source & " got backed up to " & destination)
|
||||
rsyncErrors.add("(" & nowDT & ")" & "EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to verify that " & source & " got backed up to " & destination)
|
||||
|
||||
if rsyncErrors.len > 0:
|
||||
list.runStatus = "<span color=\"#ff6b6b\" size=\"large\">Error! Please see ~/.ez-bkup/errors.log</span>"
|
||||
|
|
Loading…
Reference in New Issue