Roland's homepage

My random knot in the Web

genbackup

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

Note

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

You can download genbackup from github.

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

For comments, please send me an e-mail.


Related articles


←  foto4lb vid2mp4  →