Invoking a Pre/Post commands from a NAS?
I have a very simple/simplistic check for alteration by ransomware included as a Pre command in my backups: a .bat file on every drive containing
dir Integrity_check.txt || exit /B 1
If either the .bat file or the .txt file has been encrypted, password protected, renamed, or deleted, the command fails and the backup does not proceed.
This works fine on local - internal or USB-attached - drives but on on NAS drives. The command works fine when tested during definition of a backup task, but the command fails during execution of the backup task:
10/3/2018 11:10:52 AM: -07:00 14616 E000103F7: Failed to run a child process.
10/3/2018 11:10:52 AM: -07:00 14616 E00010401: System error: '267'.
10/3/2018 11:10:52 AM: -07:00 14616 E00640085: Execution of user command Z:/Validation/Integrity_check.bat failed. Error code: 1
I could not find any meaningful explanation of either E000103F7 or E00010401.
If the system error referred to is a Windows system error, then this means " The directory name is invalid. " but the directory name was valid when performing the test of the command during ATI task definition.
ATI has no trouble accessing directories on this drive for backup - I've been doing it for years.
Any idea how to get this to work on a NAS or should I just give up?
By the way, the forward slashes in the command are an ATI artifact created when I did a browse for the command in the task definition.


- Anmelden, um Kommentare verfassen zu können

Actually, I tried using the absolute path, but I used back slashes rather than the forward slashes ATI shows. (That's when I noticed ATI used forward slashes.) The test of the command failed.
However, I see that a successful backup uses the absolute path
10/3/2018 11:14:40 AM: -07:00 8536 I000B03F0: Create Backup Archive From: \\WDMyCloud\Public\
so I'll try again with the absolute path.
- Anmelden, um Kommentare verfassen zu können

The low down on forward/backward slash:
/
is the path separator on Unix and Unix-like systems. Modern Windows can generally use both \
and /
interchangeably for filepaths, but Microsoft has advocated for the use of \
as the path separator for decades.
This is done for historical reasons that date as far back as the 1970s, predating Windows by over a decade. In the beginning, MS-DOS (the foundation to early Windows) didn't support directories. Unix had directory support using the /
character since the beginning. However, when directories were added in MS-DOS 2.0, Microsoft and IBM were already using the /
character for command switches, and because of DOS's lightweight parser (descended from QDOS, designed to run on lower end hardware), they couldn't find a feasible way to use the /
character without breaking compatibility with their existing applications.
So, to avoid errors about "missing a switch" or "invalid switch" when passing filepaths as arguments to commands such as these:
cd/ <---- no switch specified
dir folder1/folder2 <---- /folder2 is not a switch for dir
it was decided that the \
character would be used instead, so you could write those commands like this
cd\
dir folder1\folder2
without error.
Later, Microsoft and IBM collaborated on an operating system unrelated to DOS called OS/2. OS/2 had the ability to use both separators, probably to attract more Unix developers. When Microsoft and IBM parted ways in 1990, Microsoft took what code they had and created Windows NT, on which all modern versions of Windows are based, carrying this separator agnosticism with it.
As backward compatibility has been the name of the game for Microsoft from all of the major OS transitions that they've undertaken (DOS to Win16/DOS, to Win16/Win32, to Win32/WinNT), this peculiarity stuck, and it will probably exist for a while yet.
It's for this reason that this discrepancy exists. It should really have no effect on what you're doing because, like I said, the WinAPI can generally use them interchangeably. However, 3rd party applications will probably break if you pass a /
when they expect a \
between directory names. If you're using Windows, stick with \
. If you're using Unix or URIs (which have their foundation in Unix paths, but that's another story entirely), then use /
.
- Anmelden, um Kommentare verfassen zu können

I had an absurdly difficult time getting this simple 1-line batch command to work correctly ... mostly because I don't know Windows scripting. The problem had nothing to do with the forward or backward slash. It was because the Windows "current directory" was not set when executing a .bat file via a UNC path.
The content of my .bat file now contains
dir %~dp0\Integrity_check.txt || exit /B 1
If the .bat file and Integrity_check.txt file are in the same directory the .bat file succeeds.
If the .txt file is unreadable or missing, or, obviously, if the .bat file has been corrupted and is no longer executable, the command fails.
- Anmelden, um Kommentare verfassen zu können

There you go! Glad you have it sorted now.
- Anmelden, um Kommentare verfassen zu können