Files
dotfiles/install/backup.sh
Nick Nisi 794dc843b3 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
2016-04-01 10:45:29 -05:00

30 lines
703 B
Bash
Executable File

#!/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