We will be creating a git repository with a script that backup your required dotfiles.
1. Create a folder for the backup
mkdir my-dotfiles
2. Initialize git
git init
3. Create file list
Create a file named backup.conf
at the root of the folder.
In this file we need to list out all the files & folders we need to backup. eg:
~/.gitconfig
~/.profile
~/.vimrc
~/.xinitrc
~/.zshrc
Our backup script will loop through the items and copy everything into respective folders.
4. Create script
Create a file named backup.sh
at the root of the folder.
This is our script file. Copy the content below and paste it inside the file.
#!/bin/sh
# This script copy files mentioned inside `backup.conf` to the root of the project.
# file to look for the paths to backup.
backupPaths="./backup.conf"
# home directory path.
homeDirectory=~
# same line identifier to echo in the same line.
sameLine="\e[1A\e[K"
echo "๐ Clearing configurations directory..."
# removing the folder with exsiting contents. we have git version anyway!
rm -rf configurations
# creating it again for backup.
mkdir configurations
sleep 1
echo -e "$sameLineโ
Configurations directory cleared."
sleep 1
echo -e "$sameLine๐ Starting backup..."
sleep 1
# looping through the list & avoiding the empty spaces
sed '/^[ \t]*$/d' $backupPaths | while read filePath; do
echo -e "$sameLineโณ Copying: $filePath"
# find & replace for ~ with home path
findThis="~/"
replaceWith="$homeDirectory/"
originalFile="${filePath//${findThis}/${replaceWith}}"
# copying the files
cp --parents --recursive $originalFile ./configurations
sleep 0.05
done
git add .
echo -e "$sameLine๐ Backup finished! You can review & commit your changes."
5. Make the script executable
chmod +x ./backup.sh
6. Commit all changes
git add .
git commit -m "initial commit"
7. Run script
./backup.sh
From now on, you can just run the script file whenever you need. After you run the backup script, all the files & folders mentioned inside the backup.conf
file will be copied into configurations
folder. Commit and push the changes to your remote repository.
๐ Make sure you are not adding any confidential files or folders to
backup.conf
file. eg:.ssh
or private keys.
Checkout below repository to see complete code. There is a install.sh
script in the root which is made for Arch Linux systems. Feel free to fork the repository and make changes according to your needs.
ctrleffive / linux-configurations
Linux Configurations
๐ง Linux Configurations
๐พ Backup Configurations
- Make the
backup.sh
file executable withchmod +x ./backup.sh
first. - Backup configurations by executing
backup.sh
file. - Files & folders that needs to be backed up should be mentioned inside
backup.conf
file. - Once backup is complete, commit the changes.
- If you want to restore the backup, instead of just copy paste everything back, run the backup script. After that you can use file diff to compare the changes and pick manually.
๐ซ Install Packages
- Make the
install.sh
file executable withchmod +x ./install.sh
first. - Bulk install packages by executing
install.sh
file. - Packages needs to be installed should be listed inside
install_third_party.conf
&install_trusted.conf
files. - Services needs to be enabled should be listed inside
services.conf
file. - Its better to restart the PC after script finished running.
- 3rd party packages are installed through
pikaur
AUR helper.
โก๏ธ Notes
- Install VMWare Player from here: https://wiki.archlinux.org/title/VMware#Installation
- After installing
wine
- โฆ
Top comments (0)