This repository provides a generic method to backup your files using GNU Stow. Stow is a symlink farm manager which can be used to manage your dotfiles and backups efficiently.
Before using Stow, ensure you have the following:
- GNU Stow installed on your system. You can install it using your package manager. For example:
- On Debian-based systems:
sudo apt-get install stow
- On Red Hat-based systems:
sudo yum install stow
- On macOS:
brew install stow
- On Debian-based systems:
Organize the files you want to backup into directories. Each directory should represent a category or a specific backup set. For example:
backup/
├── documents
│ ├── file1.txt
│ └── file2.txt
├── photos
│ ├── photo1.jpg
│ └── photo2.jpg
└── configs
├── .bashrc
└── .vimrc
Create a directory where you will store your stow packages. This is typically done in your home directory:
mkdir -p ~/stow-backups
Navigate to your stow directory and use Stow to create symlinks for your backup files. For example:
cd ~/stow-backups
stow -t ~ documents
stow -t ~ photos
stow -t ~ configs
This will create symlinks in your home directory pointing to the actual files in your backup directory.
If you need to remove the symlinks created by Stow, use the --delete
option:
cd ~/stow-backups
stow -D documents
stow -D photos
stow -D configs
To restore your files, simply navigate to the cloned repository and re-run the stow commands, specifying the target directory with -t
. This will recreate the symlinks in your home directory or the target directory you specified:
cd ~/your-repo
stow -t ~ documents
stow -t ~ photos
stow -t ~ configs
Assume you have the following files to backup:
.bashrc
notes.txt
photo.jpg
You can organize them as follows:
backup/
├── configs
│ └── .bashrc
├── documents
│ └── notes.txt
└── photos
└── photo.jpg
Then, you can stow them:
cd ~/stow-backups
stow -t ~ configs
stow -t ~ documents
stow -t ~ photos
To unstow (remove) them:
cd ~/stow-backups
stow -D configs
stow -D documents
stow -D photos
To restore (re-stow) them:
cd ~/your-repo
stow -t ~ configs
stow -t ~ documents
stow -t ~ photos