Skip to content

Instantly share code, notes, and snippets.

@edsoncelio
Created August 4, 2017 12:23
Show Gist options
  • Save edsoncelio/af32c9dd990c2687f373be505175983a to your computer and use it in GitHub Desktop.
Save edsoncelio/af32c9dd990c2687f373be505175983a to your computer and use it in GitHub Desktop.
Backup to my config files.
#!/bin/bash
#Script para backup de arquivos/dirs de conf importantes!
#/home/.profile
#/home/.bashrc
#/home/.vimrc
#/home/.ssh/
#/home/.oh-my-zsh/
BK_DIR=/tmp/$(hostname -s)_$(date +%d-%m-%y)
BK_OUT=/tmp/backup_$(date +%d-%m-%y).cpio
LG_FILE=/tmp/bk_log.log
#TODO: melhorar verificacao da existencia do dir de backup
if [ -d $BK_DIR ]; then
rm -R $BK_DIR;mkdir $BK_DIR
else
mkdir $BK_DIR
fi
if [ -e $LG_FILE ]; then
rm $LG_FILE
fi
if [ -e $HOME/.profile ]; then
echo "copiando o arquivo ..."
cp $HOME/.profile $BK_DIR 2> $LG_FILE
fi
if [ -e $HOME/.bashrc ]; then
echo "copiando o arquivo ..."
cp $HOME/.bashrc $BK_DIR 2> $LG_FILE
fi
if [ -d $HOME/.ssh/ ]; then
echo "copiando o arquivo ..."
cp -r $HOME/.ssh $BK_DIR 2> $LG_FILE
fi
if [ -d $HOME/.oh-my-ssh/ ]; then
echo "copiando o arquivo ..."
cp -r $HOME/.oh-my-ssh $BK_DIR 2> $LG_FILE
fi
if [ -e $HOME/.vimrc/ ]; then
echo "copiando o arquivo ..."
cp -r $HOME/.vimrc $BK_DIR 2> $LG_FILE
fi
#TODO: não achei uma forma de arrumar isso ainda!
ls $BK_DIR | cpio -o > $BK_OUT 2> $LG_FILE
echo "Backup salvo em: " $BK_OUT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment