Last active
June 21, 2021 03:50
-
-
Save Nezteb/c232a6421f90bf0548b11e372ccde163 to your computer and use it in GitHub Desktop.
A script I use to back stuff up
This file contains 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
#!/bin/bash | |
# CHANGE THESE | |
SUFFIX="personal" | |
BACKUPS_DIR="${HOME}/SomeCloudStorage/backups/${SUFFIX}" | |
PROFILE_FILENAME="zshrc" # bash_profile, bashrc, zshrc, etc. (without dots) | |
echo "Starting backup script..." | |
mkdir -p "${BACKUPS_DIR}" | |
date >"${BACKUPS_DIR}/_date_of_last_backup_${SUFFIX}.txt" | |
# Applications list | |
echo "Backing up Applications list..." | |
ls /Applications >"${BACKUPS_DIR}/applications_list_${SUFFIX}.txt" | |
# Brew leaves | |
[ -x "$(command -v brew)" ] && | |
echo "Backing up Homebrew leaves..." && | |
brew leaves >"${BACKUPS_DIR}/brew_leaves_${SUFFIX}.txt" | |
# SSH directory | |
echo "Backing up SSH directory..." | |
zip -qr "${BACKUPS_DIR}/ssh_${SUFFIX}.zip" "${HOME}/.ssh" | |
echo "Backing up ${PROFILE_FILENAME}..." | |
PROFILE_DEST="${BACKUPS_DIR}/${PROFILE_FILENAME}_${SUFFIX}" | |
cp "${HOME}/.${PROFILE_FILENAME}" "${PROFILE_DEST}" | |
# If using profile directories | |
[ -d "${HOME}/.${PROFILE_FILENAME}s" ] && | |
echo "Backing up ${PROFILE_FILENAME}s directory..." && | |
PROFILES_DEST="${BACKUPS_DIR}/${PROFILE_FILENAME}s_${SUFFIX}.zip" && | |
zip -qr "${PROFILES_DEST}" "${HOME}/.${PROFILE_FILENAME}s" | |
# If using oh-my-zsh | |
[ -d "${HOME}/.oh-my-zsh" ] && | |
echo "Backing up oh-my-zsh directory..." && | |
zip -qr "${BACKUPS_DIR}/oh-my-zsh_${SUFFIX}.zip" "${HOME}/.oh-my-zsh" | |
# If using gnupg | |
[ -d "${HOME}/.gnupg" ] && [ -x "$(command -v gpg)" ] && | |
echo "Backing up gnupg directory..." && | |
gpg --list-signatures >"${BACKUPS_DIR}/gpg-signatures_${SUFFIX}.txt" && | |
gpg --list-secret-keys >"${BACKUPS_DIR}/gpg-signatures_${SUFFIX}.txt" && | |
gpg --armor --export-secret-keys >"${BACKUPS_DIR}/gpg-secret-keys_${SUFFIX}.txt" && | |
gpg --armor --export >"${BACKUPS_DIR}/gpg-public-keys_${SUFFIX}.txt" && | |
zip -qr "${BACKUPS_DIR}/gnupg_${SUFFIX}.zip" "${HOME}/.gnupg" >/dev/null 2>&1 # Prints warnings about operations on sockets | |
# VS Code extensions | |
[ -x "$(command -v code)" ] && | |
echo "Backing up VS Code extensions list..." && | |
code --list-extensions >"${BACKUPS_DIR}/vs_code_extensions_${SUFFIX}.txt" | |
# If using kitty | |
[ -d "${HOME}/.config/kitty" ] && | |
echo "Backing up kitty directory..." && | |
zip -qr "${BACKUPS_DIR}/kitty_${SUFFIX}.zip" "${HOME}/.config/kitty" | |
# If using nvim | |
[ -d "${HOME}/.config/nvim" ] && | |
echo "Backing up nvim directory..." && | |
zip -qr "${BACKUPS_DIR}/nvim_${SUFFIX}.zip" "${HOME}/.config/nvim" | |
# If using coc with nvim | |
[ -d "${HOME}/.config/coc" ] && | |
echo "Backing up coc directory..." && | |
zip -qr "${BACKUPS_DIR}/coc_${SUFFIX}.zip" "${HOME}/.config/coc" | |
echo "Done backing up." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment