Roland's homepage

My random knot in the Web


This shell-script makes a backup (with the tar program) of the directory from which it is called, with all its contents. It is one of the smallest scripts I’ve ever written but I’ve found it really useful to make fast complete backups of e.g. source archives.

The name of the backup file starts with backup, followed by the name of the directory. If that directory is hidden (it’s name starts with a ‘.’), then that ‘.’ is replaced by the text ‘dot’. If this directory is under revision control by git, it appends the short hash tag to the name of the backup file.

So if this script is called e.g. from the directory ~/src/scripts which is under revision control by git, the name of the backup will be e.g. backup-scripts-b51dee1.tar.gz. A backup of ~/.foo (which is not under revision control) will be backup-dotfoo.tar.gz


Before making the backup, it deletes all older backup tarfiles found in the same directory.

You can download genbackup from github.

  • pwd
  • basename
  • tar
  • git when making backups of directories under git control


creative commons public domain logo

To the extent possible under law, Roland Smith has waived all copyright and related or neighboring rights to genbackup. This work is published from the Netherlands.

←  foto4lb vid2mp4  →