add backup script, cleanup link script

* add initial stab at a backup script to copy existing files to a backup directory
* clean up unused code in link.sh
This commit is contained in:
Nick Nisi
2016-04-01 10:45:29 -05:00
parent 9e841588b6
commit 794dc843b3
2 changed files with 30 additions and 3 deletions

29
install/backup.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/usr/bin/env bash
# Backup files that are provided by the dotfiles into a ~/dotfiles-backup directory
DOTFILES=$HOME/.dotfiles
BACKUP_DIR=$HOME/dotfiles-backup
set -e # TODO: what does this do?
echo "Creating backup directory at $BACKUP_DIR"
mkdir -p $BACKUP_DIR
linkables=$( find -H "$DOTFILES" -maxdepth 3 -name '*.symlink' )
for file in $linkables; do
filename=".$( basename $file '.symlink' )"
target="$HOME/$filename"
if [ -e $target ]; then
echo "backing up $filename"
cp $target $BACKUP_DIR
fi
done
typeset -a files=($HOME/.config/nvim $HOME/.vim $HOME/.vimrc)
for file in $files; do
if [ -e $file ]; then
cp -rf $file $BACKUP_DIR
fi
done