A backup of my custom configuration files together with scripts for their maintenance.
dotfiles script is responsible for restoring and backing up custom
configuration files and directories listed under its FILES array. Items in
FILES array are paths. If a path starts with HOME, it refers to the
${HOME} directory at a user's side and to the HOME directory that lies in
the same directory as the script at the script's side.
To backup the dot files, type
./dotfiles backupTo restore them back, type
./dotfiles restoreTo get the help, type
./dotfiles --helpAdditionally, backup and restore accepts also arguments specifying
particular files. An argument is either a path as described above or an index
to the FILES array. Examples:
./dotfiles backup 0 HOME/.bashrcbackups~/.bashrcand${FILES[0]}./dotfiles restore 1restores${FILES[1]}
When you type ./dotfiles --help, you may notice something like this
Restore or backup dot files or directories.
Usage: dotfiles OPTIONS {restore,backup} [FILES]
where OPTIONS are
-b, --backup
make a backup of old files or directories when restoring; a name
of a backup has a form <old file name>.XXXXX.bak, where XXXXX is
generated by `mktemp -u`; a backup is placed in the same
directory as its original;
-d, --dry-run
print what will be done without taking any action;
-h, -?, --help
print this help and exit;
-q, --quite
restore or backup files or directories quitely;
`dotfiles restore` restores files or directories from the script
directory, `dotfiles backup` backup files or directories to the script
directory.
FILES can further specify which files or directories should be restored
or backed up. A file or directory can be specified both as an index to
the FILES array (see the list of files below) or a path starting with
`HOME`, which denotes home directory.
The list of files or directories that will be restored or backed up is:
0: /home/jdoe/jdoes_projects/dotfiles/HOME/.bashrc.d <-> /home/jdoe/.bashrc.d
Notice the last line. Suppose that your user name is jdoe and your home
directory is then /home/jdoe. Suppose that you have dotfiles cloned in
/home/jdoe/jdoes_projects directory and you are cded in it so if you type
echo ${PWD} you will see /home/jdoe/jdoes_projects/dotfiles. Suppose the
path to dotfiles script is /home/jdoe/jdoes_projects/dotfiles/dotfiles.
Now what the last line means. In a case you type ./dotfiles backup, file
/home/jdoe/.bashrc.d is copied to
/home/jdoe/jdoes_projects/dotfiles/HOME/.bashrc.d location. Conversely, if
you type ./dotfiles restore,
/home/jdoe/jdoes_projects/dotfiles/HOME/.bashrc.d is copied to
/home/jdoe/.bashrc.d location.