alexpgp: (Visa)
Yes, it says "Crom!" in all the Robert E. Howard books, but in my ceaseless quest for a good dose of cognitive dissonance, I like to think the Cimmerian was secretly a Unix user (cron being the name of the time-based job scheduler in Unix-like operating systems). But I digress...

So I get this idea last year (not so long ago, really) to create a daily job to back up the invoice database that's on my Raspberry Pi. This would appear to be a cinch, as there are a pile of places on the Web that'll tell you how to do this. The place I chose explained things straightforwardly, suggesting that the output of the mysqldump command could be piped to gzip as follows:
... | gzip > /media/usb/database_`date +%m-%d-%Y`.sql.gz
It worked like a charm from the command line, and after editing the line slightly to render the date in YYYY-MM-DD format, I created a "cron job" set to run every morning at 12:11 am.

Unfortunately, cron treats percent signs (%) in a very special way—the first one signals the start of stdin, and the rest get converted to newlines—so my carefully crafted job description turned to dross rather quickly. Attempting to "escape" this treatment of the percent sign with a backslash (`date +\%m-\%d-\%Y`) keeps the percent sign, but the backslashes as well.

Fortunately, I found a way to specify the date format that I wanted without using percent signs (`date --rfc-3339='date'`) and everything works.

Good to find this kind of stuff out now, instead of after a need arises to restore the database.

Profile

alexpgp: (Default)
alexpgp

January 2018

S M T W T F S
  1 2 3456
7 8910111213
14 15 16 17181920
21222324252627
28293031   

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 10th, 2025 07:26 am
Powered by Dreamwidth Studios