Skip to content

Instantly share code, notes, and snippets.

@eboye
Created November 9, 2022 22:24
Show Gist options
  • Save eboye/5d86d12f6aa5b309e77eb9f649dccbfe to your computer and use it in GitHub Desktop.
Save eboye/5d86d12f6aa5b309e77eb9f649dccbfe to your computer and use it in GitHub Desktop.
#!/bin/bash
# check to see is git command line installed in this machine
IS_GIT_AVAILABLE="$(git --version)"
if [[ $IS_GIT_AVAILABLE == *"version"* ]]; then
echo "Git is Available"
else
echo "Git is not installed"
exit 1
fi
# check to see is rsync command line installed in this machine
IS_RSYNC_AVAILABLE="$(rsync --version)"
if [[ $IS_RSYNC_AVAILABLE == *"version"* ]]; then
echo "rsync is Available"
else
echo "rsync is not installed"
exit 1
fi
# Copy .dotfiles
cp "$HOME"/{.bash_profile,.bashrc,.flutter,.nanorc,.p10k.zsh,.wakatime.cfg,.zshrc} .
# Copy .cacher folder
cp -r "$HOME"/.cacher/ .
# Copy .cloudflared folder
cp -r "$HOME"/.cloudflared/ .
# Copy .fromscratch folder
cp -r "$HOME"/.fromscratch/ .
# Copy .icons folder
cp -r "$HOME"/.icons/ .
# Copy .nano folder
cp -r "$HOME"/.nano/ .
# Copy .oh-my-zsh folder
cp -r "$HOME"/.oh-my-zsh/ .
# Copy .ssh folder
cp -r "$HOME"/.ssh/ .
# Copy .tableplus folder
cp -r "$HOME"/.tableplus/ .
# Copy .vnc folder
cp -r "$HOME"/.vnc/ .
# Copy .wakatime folder
cp -r "$HOME"/.wakatime/ .
# Copy .config excluding some folders
rsync -av --progress "$HOME"/.config . \
--exclude heroic \
--exclude BraveSoftware \
--exclude figma-linux/Code\ Cache \
--exclude figma-linux/Cache \
--exclude figma-linux/GPUCache \
--exclude luckynote-nativefier-6b2d5c \
--exclude microsoft-edge-beta \
--exclude google-chrome-beta \
--exclude cef_user_data \
--exclude chromium \
--exclude Ray \
--exclude Ledger\ Live \
--exclude Authy\ Desktop/Cache \
--exclude Authy\ Desktop/Code\ Cache \
--exclude Cacher/Cache \
--exclude Cacher/Code\ Cache \
--exclude pritunl/Cache \
--exclude pritunl/Code\ Cache \
--exclude dockstation/Cache
# Check git status
gs="$(git status | grep -i "modified")"
echo "${gs}"
# If there is a new change
if [[ $gs == *"modified"* ]]; then
echo "push"
fi
# push to Github
git add .;
git commit -m "New backup $(date +'%Y-%m-%d %H:%M:%S')";
git push origin main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment