Last active
December 2, 2019 18:30
-
-
Save hinell/c09cb5bfdd5e69811af6647d0f686413 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!sh | |
#--------<SETTING UP DEFAULT FOLDERS>-------- | |
BackUpFolder=/e/Backup; | |
BackUpFolderUser=$BackUpFolder/user; | |
echo "| Info" | |
echo "| Script : User Files Backup script" | |
echo "| AUTHOR : Alexnader Davronov" | |
echo "| MODIFIED at : 2.12.2019" | |
echo "| BACK UP FOLDER is : $BackUpFolder" | |
report(){ | |
echo "$1| [$2] --> [$3]" | |
} | |
# --------< HELPER FUNCTIONS >-------- | |
backUpListHelp() { | |
local indent=$1 | |
echo "" | |
echo "${indent}Usage: backUpList <title> <src> <dst> <files>" | |
echo "${indent} <title> - name of the backuping" | |
echo "${indent} <src> - source folder where to read files" | |
echo "${indent} <dst> - destination folder where to save files" | |
echo "${indent} <files> - list of \n delimited strings" | |
echo "" | |
} | |
backUpList () { | |
local err="ERROR: INVALID ARGUMENT: " | |
local errIndt=" "; | |
local title=$1 | |
local src=$2 | |
local dst=$3 | |
local files=$4 | |
echo | |
echo " Backuping $title :" | |
echo " source : $src" | |
echo " destination: $dst" | |
if (test -z "$title"); | |
then | |
title="user files" | |
fi | |
if (test -z "$src"); | |
then | |
backUpListHelp $errIndt; | |
echo "$errIndt$err <src> is missing!"; | |
exit | |
fi | |
if (test -z "$dst"); | |
then | |
backUpListHelp $errIndt; | |
echo "$errIndt$err <dst> is missing!"; | |
exit | |
fi | |
if (test -z "$files"); | |
then | |
backUpListHelp $errIndt; | |
echo "$errIndt$err <files> is missing!"; | |
exit | |
fi | |
for file in $files | |
do | |
cp -uR $src/$file $dst | |
# rm $BackUpFolder/$file | |
report " " "${file}" "$dst/$file" | |
done | |
echo " " "✔" | |
} | |
dir_make () { | |
local dir=$1 | |
# Check if folder exists | |
if ( ! test -e $dir ); | |
then | |
mkdir -p $dir | |
fi | |
} | |
#--------<RUN>-------- | |
# keybindings.json | |
# settings.json | |
# syncLocalSettings.json | |
#--------<BACKUP VS CODE PROFILE>-------- | |
# Copies list of VS Code settings and extensions | |
# To get list of extensions run: | |
# code --list-extensions > $VSCBackupDst/$VSCExtensionsFileName | |
# To install extensions run: | |
# cat $VSCodeExentionsFile | xargs -L 1 code code install-extension | |
# Extensiosn list file name (isn't standard) | |
VSCExtensionsFileName=".extensions" | |
VSCBackupSrc="$HOME/appData/Roaming/Code/User" | |
VSCBackupDst="$BackUpFolderUser/appData/Roaming/Code/User" | |
code --list-extensions > $VSCBackupDst/$VSCExtensionsFileName | |
echo | |
echo "Exporting code exetnsions into temp file" | |
report " " "code extensions" "$VSCExtensionsFileName" | |
dir_make $VSCBackupDst | |
backUpList "VS Code" $VSCBackupSrc $VSCBackupDst " | |
globalStorage | |
snippets | |
keybindings.json | |
settings.json | |
syncLocalSettings.json | |
" | |
# --------<BACK UP GIT FILES>-------- | |
backUpList "GIT settings" $HOME $BackUpFolderUser " | |
.bash_history | |
.bash_profile | |
.bashrc | |
.cmdrc.cmd | |
.dbshell | |
.gitconfig | |
.mongorc.js | |
.node_repl_history | |
.npmrc | |
.yarnrc | |
docker | |
docker-machine | |
" | |
ConEmuPath="/e/TotalCommander/PortableProgram/ConEmuPack" | |
backUpList "ConEmu settings" $ConEmuPath $BackUpFolderUser " | |
ConEmu.xml | |
" | |
#--------<COPY ITSELF TO THE BACKUP FOLDER>-------- | |
echo "Backuping itself" | |
report " " "backup.user.sh" "$BackUpFolderUser/backup.user.sh" | |
cp $0 $BackUpFolderUser | |
echo "✔ Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment