Locate the source directory, its parent and the output file
Suppose the staging directory is /mnt/ssd/backups/clone-20261202-0900. Check df -h /mnt/ssd/backups and mount to verify the path resides on the intended SSD. Use ls -ld to confirm that this run actually created the directory. If the mount directory exists but df shows the root filesystem, fix the mount before another backup fills the router's flash.
Use the following block after creating the staging directory, with a timestamp unique to the job. Set D to its absolute path. The temporary archive goes in the same parent directory and gets its final name only after it passes the listing check.
test -d "$D" || exit 1
parent=$(dirname "$D")
name=$(basename "$D")
umask 077
archive="$parent/$name.tar.gz"
test ! -e "$archive" || exit 1
partial=$(mktemp "$parent/.clone-XXXXXX") || exit 1
tar -czf "$partial" -C "$parent" "$name" &&
tar -tzf "$partial" >/dev/null &&
mv "$partial" "$archive" || exit 1
Check whether the archive is usable

The screenshot uses a temporary directory on OpenWrt 25.12.6 x86/64. The first tar command exits with 1. The second archive yields ok when its member is read back. This tests the lookup path. Verify the actual SSD mount on your own router.
Run tar -tzf ARCHIVE on the new backup and locate a required member from this run. Extract it in a private directory and compare its contents. If tar reports insufficient space or a read-only filesystem, retain the staging directory and the previous good archive, fix storage and retry. Do not send a leftover partial file as a backup. Print the success message only after validation.
Why does the root filesystem on a NanoPi R4S fill up when a USB disk is attached?
On an R4S running 25.12.0, pause scheduled backups if the script writes to /mnt/sda1. Substitute the real destination in the following commands. Compare device identifiers, saved configuration, active mounts and free space in the same session.
block info
uci show fstab
cat /proc/mounts
df -h / /mnt/sda1
If the destination directory exists but the mount table has no corresponding data disk, writes consume space on the filesystem containing the directory. If the UUID in fstab differs from block info, back up /etc/config/fstab first, then correct only the entry for the identified volume and mount point. Remount during a maintenance window. Check the mount table, df for both paths and a known file on the disk before restarting backups. A later mount can hide files previously written to the root filesystem. Identify those files and keep a copy before arranging cleanup.
Related reading · OpenWrt sysupgrade.conf: keep custom scripts and verify the backup
Comments