Automating backups (local to router)

I've mounted a USB drive at /mnt/nlbwdb/

I'd like to automake system backups but keep 5 and delete the rest:

I tried:
# /sbin/sysupgrade --create-backup '/mnt/nlbwdb/system-config-backups/uname -n-date +%Y-%m-%d.tar.gz'
but that didn't run the uname and date commands.
I just got a file called uname -n-date +%Y-%m-%d.tar.gz

Assuming I can fix that I don't know how to delete old backups.
Maybe the find command?

Assuming what you actually meant to type is:

(aside: use the "preformatted text" option in the editor (the icon that looks like </>) to format code)

This doesn't work because single-quotes disable variable interpolation. Use double-quotes if you need variable interpolation to work. Example:

/sbin/sysupgrade --create-backup "/mnt/nlbwdb/system-config-backups/$(uname -n)-$(date +%Y-%m-%d).tar.gz"

Also note the use of the newer, easier-to-read, and POSIX-compatible $() syntax instead of backticks for command substitutions.

It should be in /mnt/nlbwdb/system-config-backups, no? I re-read this again and realized what you're really asking is "how can I keep only the newest 5 backups and delete everything else". This sounds like it would be better handled with real backup utility like duplicity, but I presume you want a solution that uses only default tools. You might try the solutions to this question, which seems to be completely analogous to your situation.


This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.