Hyprland-dotfiles/.install/backup.sh

48 lines
1.9 KiB
Bash
Raw Normal View History

2023-11-10 16:12:15 -05:00
# ------------------------------------------------------
# Backup existing dotfiles
# ------------------------------------------------------
datets=$(date '+%Y%m%d%H%M%S')
2023-11-12 08:16:53 -05:00
if [ -d ~/dotfiles ] || [ -f ~/.bashrc ]; then
2023-11-17 07:48:02 -05:00
echo -e "${GREEN}"
2023-12-21 15:57:44 -05:00
figlet "Backup"
2023-11-17 07:48:02 -05:00
echo -e "${NONE}"
2023-11-12 08:16:53 -05:00
if [ -d ~/dotfiles ]; then
2024-01-25 14:55:32 -05:00
echo ":: The script has detected an existing dotfiles folder and will try to create a backup into the folder:"
echo " ~/dotfiles-versions/backups/$datets"
2023-11-12 08:16:53 -05:00
fi
2023-11-17 07:48:02 -05:00
if [ ! -L ~/.bashrc ] && [ -f ~/.bashrc ]; then
2024-01-25 14:55:32 -05:00
echo ":: The script has detected an existing .bashrc file and will try to create a backup to:"
echo " ~/dotfiles-versions/backups/$datets/.bashrc-old"
2023-11-12 08:16:53 -05:00
fi
2023-11-20 16:24:53 -05:00
if gum confirm "Do you want to create a backup?" ;then
2023-11-20 16:11:39 -05:00
if [ ! -d ~/dotfiles-versions ]; then
mkdir ~/dotfiles-versions
echo "~/dotfiles-versions created."
fi
if [ ! -d ~/dotfiles-versions/backups ]; then
mkdir ~/dotfiles-versions/backups
echo "~/dotfiles-versions/backups created"
fi
if [ ! -d ~/dotfiles-versions/backups/$datets ]; then
mkdir ~/dotfiles-versions/backups/$datets
echo "~/dotfiles-versions/backups/$datets created"
fi
if [ -d ~/dotfiles ]; then
rsync -a ~/dotfiles/ ~/dotfiles-versions/backups/$datets/
2024-01-25 14:55:32 -05:00
echo ":: Backup of your current dotfiles in ~/dotfiles-versions/backups/$datets created."
2023-11-20 16:11:39 -05:00
fi
if [ -f ~/.bashrc ]; then
cp ~/.bashrc ~/dotfiles-versions/backups/$datets/.bashrc-old
2024-01-25 14:55:32 -05:00
echo ":: Existing .bashrc file found in homefolder. .bashrc-old created"
2023-11-20 16:11:39 -05:00
fi
2024-02-22 11:42:19 -05:00
echo
echo ":: PLEASE NOTE: You can create a fresh installation of teh dotfiles by removing the folder ~/dotfiles"
2023-11-21 15:19:51 -05:00
elif [ $? -eq 130 ]; then
exit 130
2023-11-20 16:11:39 -05:00
else
2024-01-25 14:55:32 -05:00
echo ":: Backup skipped."
2023-11-20 16:11:39 -05:00
fi
2023-11-10 16:12:15 -05:00
echo ""
fi