diff options
author | Christian Hesse <mail@eworm.de> | 2021-04-29 16:07:33 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2021-04-29 21:29:32 +0200 |
commit | 51007f922456597466f01d643d9c9d554bd4cae7 (patch) | |
tree | a5a66a4347b9a1669ddaf80ae728662e0866cf97 /upload-backup | |
parent | ff4e5339d0103f73bf36f4b63f7ce8970d25e29f (diff) |
upload-backup: work inside directory
Diffstat (limited to 'upload-backup')
-rw-r--r-- | upload-backup | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/upload-backup b/upload-backup index 921b196..08b4adf 100644 --- a/upload-backup +++ b/upload-backup @@ -24,6 +24,7 @@ :global DeviceInfo; :global IfThenElse; :global LogPrintExit2; +:global MkDir; :global RandomDelay; :global ScriptFromTerminal; :global SendNotification2; @@ -42,20 +43,25 @@ $WaitFullyConnected; $RandomDelay $BackupRandomDelay; } +:if ([ $MkDir $0 ] = false) do={ + $LogPrintExit2 error $0 ("Failed creating directory!") true; +} + # filename based on identity :local FileName [ $CharacterReplace ($Identity . "." . $Domain) "." "_" ]; +:local FilePath ($0 . "/" . $FileName); :local BackupFile "none"; :local ConfigFile "none"; :local Failed 0; # binary backup :if ($BackupSendBinary = true) do={ - / system backup save encryption=aes-sha256 name=$FileName password=$BackupPassword; - $WaitForFile ($FileName . ".backup"); + / system backup save encryption=aes-sha256 name=$FilePath password=$BackupPassword; + $WaitForFile ($FilePath . ".backup"); :do { / tool fetch upload=yes url=($BackupUploadUrl . "/" . $FileName . ".backup") \ - user=$BackupUploadUser password=$BackupUploadPass src-path=($FileName . ".backup"); + user=$BackupUploadUser password=$BackupUploadPass src-path=($FilePath . ".backup"); :set BackupFile ($FileName . ".backup"); } on-error={ $LogPrintExit2 error $0 ("Uploading backup file failed!") false; @@ -66,12 +72,12 @@ $WaitFullyConnected; # create configuration export :if ($BackupSendExport = true) do={ - / export terse file=$FileName; - $WaitForFile ($FileName . ".rsc"); + / export terse file=$FilePath; + $WaitForFile ($FilePath . ".rsc"); :do { / tool fetch upload=yes url=($BackupUploadUrl . "/" . $FileName . ".rsc") \ - user=$BackupUploadUser password=$BackupUploadPass src-path=($FileName . ".rsc"); + user=$BackupUploadUser password=$BackupUploadPass src-path=($FilePath . ".rsc"); :set ConfigFile ($FileName . ".rsc"); } on-error={ $LogPrintExit2 error $0 ("Uploading configuration export failed!") false; |