Schnapps: No *.info file created when called from a script

Hi everyone,

I made a script to create new snapshot and export it to USB drive.

I have problem with export to the USB drive. The export creates both *.tar.gz and *.info files when executing the command using SSH connection.

Unfortunately, it looks like the *.info file is not created when calling Schnapps from the script. The script is called by the cron.

Any idea what can be wrong?

Here are additional details:
MOX running TOS 5.2.7

USB Drive: SanDisk Corp. Cruzer Fit, FAT32 formatted

Script is triggered by the cron, stored in /etc/ and rights set to 0755.

The script itself looks like this:

# Create new snapshot
schnapps create -t time "bckp-to-USB"

# Get number of the latest schnapshot created using Schnapps
LatestSnapshot=$(schnapps list -j | python -c "import sys, json; print(json.load(sys.stdin)['snapshots'][-1]['number'])")

# Create a directory to be the mount point for the USB drive.
mkdir /mnt/usb

# Mount the /dev/sda1 device (the first partition of the USB drive) to the mount point.
mount /dev/sda1 /mnt/usb

# Create directory “old_snapshots” in case it is missing
mkdir -p /mnt/usb/old_snapshots

# Move existing snapshots (if any) to old_snapshots (with overwriting)
mv -f /mnt/usb/*-medkit-* /mnt/usb/old_snapshots

# Export the latest snapshot to the USB drive
schnapps export $LatestSnapshot /mnt/usb

# Unmount the /mnt/usb mount point
umount /mnt/usb

# Remove the directory used for the mount point
rmdir /mnt/usb

I cannot reproduce your problem. Both files are created.

Check if your LatestSnapshot variable is filled in properly, if it is empty it will export currently running snapshot without creating an .info file.

I tried the script above „as is“ and it creates both files.

Hi @hagrid and @miska, thank you for looking in to this.

I spent some more time investigating the behavior.

Now I am certain, that

  • The variable LatestSnapshot is filled in properly
  • The issue is not replicable when calling the script from terminal
  • The issue occurs only when calling the script from cron

The cronjob is defined as follows:
0 0 * * WED /etc/

Any idea what might be wrong? Is the cronjob defined properly? Shall I try different time?