miracle2k/tarsnapper

Feature request: allow globs in source paths

jefft opened this issue · 5 comments

It would be nice if one could include globs in source paths:

  myscripts:
      sources:
        - /path/to/*.py
        - /path/to/*.sh

to get the equivalent of the shell expression:

tarsnap -cf myscripts /path/to/*.py /path/to/*.sh

While just using Python's glob.glob() would do the trick, perhaps just letting shell expansions operate would be more powerful and reduce surprises (often one tests raw tarsnap commands first before encoding them in tarsnapper).

I've referenced a one-line change that lets the shell expand globs.

Currently if a source path/directory does not exist, tarsnapper emits an error. Eg this:

 myscripts:
      sources:
        - /path/to/*.py
        - /path/to/*.invalid

gives:

Not backing up 'myscripts', because not all given sources exist

The tip of my branch eliminates this code (which would not work with shell expansions) and relies on tarsnap error reporting, which gives more specific errors anyway:

Creating backup myscripts: myscripts.20140509-154859
tarsnap execution failed:
tarsnap: /path/to/*.invalid: Cannot stat: No such file or directory
                                       Total size  Compressed size
All archives                               5.1 GB           4.1 GB
  (unique data)                            2.2 GB           1.5 GB
This archive                               1.4 kB           1.3 kB
New data                                    439 B           1.0 kB
tarsnap: Error exit delayed from previous errors.

The reason the warning exists is because I had this particular use-case where some backup sources may legitimately not be available at backup time.

I don't think I care anymore, and probably no one else does either, so I do believe we could get rid of it.

Wondering if this was still considered? I would love globbing as well, I'd like to backup the rrd data from a Munin master, but I can't do /var/lib/munin/**/*.rrd and I don't want any of the other non-rrd files in there.

I'd merge a pull request!