Skip to content

Automated Backup

TomfromBerlin edited this page Feb 13, 2023 · 2 revisions

The automatic backup only works within the Bourne Again Shell, since other shells have different filenames for their .*shrc files. There is no workaround implemented yet.

With this .bashrc every time you start a terminal it will check if the directory ~/.shellcfg/backup exists. If not, it will create it and backup the following files:

~/.bashrc
~/.shellcfg/alias
~/.shellcfg/colors
~/.shellcfg/functions
~/.shellcfg/what_shell

Just these files. The backup files are named .backup resp. .backup~ (You'll have two versions of the backup). Although the directory ~/.shellcfg/ is hidden the content inside of it is not. You can navigate to the directory with cd ~/.shellcfg/ and display the content with the ls command or just enable "Show hidden files" in your favorite file manager.

If you messed up and want to roll back, you need to copy the backup files back to its original location

cp -i ~/.shellcfg/backup/bashrc.backup ~/.bashrc 
cp -i ~/.shellcfg/backup/alias.backup  ~/.shellcfg/alias
...

and so on.

You should have a basic knowledge of file management, e.g. how to copy, move, and rename files. For more information use man cp or man mv at the command line. Or, to keep it simple, use a file manager like the mighty Midnight Commander (apt-get install mc). You can summon this beast by typing mc on the console and pressing Enter.