Numbered file backups – Easy as can beasy

file-twoWhen I’m about to edit a configuration file or a bash script, sometimes I don’t know if the edit will work. In these cases I create a backup of it in numbered order (to keep track of them if I need to revert the changes). Because this is something I regularly do, I decided to build a script to make this easy. The usage is basic: define the file and destination-directory:

# bckfile definedfile.bash .
‘/home/johndoe/.local/bin/definedfile.bash’ -> ‘/home/johndoe/.local/bin/definedfile_00.bash’

Optionally a tag can be added too:

bckfile youdle .vault/ new
‘/home/johndoe/.local/bin/youdle’ -> ‘/home/johndoe/.local/bin/youdle_02-new’

A limitation of the script is that filename cannot have ‘periods’ in their filename. A heuristics of discovering multiple extensions and with . in the filename itself would be tough.

About these ads

About Todd Partridge (Gently)

Good times, good people, good fun.

Posted on 2013-12-24, in Command Line, Linux, Script. Bookmark the permalink. Leave a comment.

Comments are closed.

Follow

Get every new post delivered to your Inbox.

Join 52 other followers

%d bloggers like this: