Skip to content

Instantly share code, notes, and snippets.

@cheeseonamonkey
Last active October 18, 2024 19:45
Show Gist options
  • Save cheeseonamonkey/eaea671df9f6384276107a96214b2680 to your computer and use it in GitHub Desktop.
Save cheeseonamonkey/eaea671df9f6384276107a96214b2680 to your computer and use it in GitHub Desktop.
backup_home.zsh
#!/bin/bash
# Set the backup filename
BACKUP_FILE="home_backup_$(date +%Y%m%d).squashfs"
# Create a temporary directory to hold the files to be backed up
TEMP_DIR=$(mktemp -d)
# Copy the files to the temporary directory
cp -r "$HOME"/.bash_logout "$TEMP_DIR"
cp -r "$HOME"/.bashrc "$TEMP_DIR"
cp -r "$HOME"/.bookmarks "$TEMP_DIR"
cp -r "$HOME"/.dmrc "$TEMP_DIR"
cp -r "$HOME"/.emulator_console_auth_token "$TEMP_DIR"
cp -r "$HOME"/.festival_history "$TEMP_DIR"
cp -r "$HOME"/.flutter "$TEMP_DIR"
cp -r "$HOME"/.gitconfig "$TEMP_DIR"
cp -r "$HOME"/.kotlinc_history "$TEMP_DIR"
cp -r "$HOME"/.lesshst "$TEMP_DIR"
cp -r "$HOME"/.netrc "$TEMP_DIR"
cp -r "$HOME"/.nix-defexpr "$TEMP_DIR"
cp -r "$HOME"/.omnisharp "$TEMP_DIR"
cp -r "$HOME"/.pandastable "$TEMP_DIR"
cp -r "$HOME"/.profile "$TEMP_DIR"
cp -r "$HOME"/.ptpython "$TEMP_DIR"
cp -r "$HOME"/.recently-used "$TEMP_DIR"
cp -r "$HOME"/.sqliterc "$TEMP_DIR"
cp -r "$HOME"/.wget-hsts "$TEMP_DIR"
cp -r "$HOME"/.Xauthority "$TEMP_DIR"
cp -r "$HOME"/.Xdefaults "$TEMP_DIR"
cp -r "$HOME"/.xscreensaver "$TEMP_DIR"
cp -r "$HOME"/.yarnrc "$TEMP_DIR"
cp -r "$HOME"/.zprofile "$TEMP_DIR"
cp -r "$HOME"/.zshenv "$TEMP_DIR"
cp -r "$HOME"/.allennlp "$TEMP_DIR"
cp -r "$HOME"/.devilspie "$TEMP_DIR"
cp -r "$HOME"/.ipynb_checkpoints "$TEMP_DIR"
cp -r "$HOME"/.kaggle "$TEMP_DIR"
cp -r "$HOME"/.sqlite_history "$TEMP_DIR"
cp -r "$HOME"/.streamlit "$TEMP_DIR"
cp -r "$HOME"/.swt "$TEMP_DIR"
cp -r "$HOME"/.viminfo "$TEMP_DIR"
cp -r "$HOME"/.vscode-react-native "$TEMP_DIR"
cp -r "$HOME"/.w3m "$TEMP_DIR"
cp -r "$HOME"/.yarn "$TEMP_DIR"
cp -r "$HOME"/.zshrc "$TEMP_DIR"
mkdir -p "$TEMP_DIR/.config/"
cp -r "$HOME/.config/copyq" "$TEMP_DIR/.config/"
cp -r "$HOME/.config/obsidian" "$TEMP_DIR/.config/"
cp -r "$HOME/.config/nvim" "$TEMP_DIR/.config/"
cp -r "$HOME/.config/browsh" "$TEMP_DIR/.config/"
cp -r "$HOME/.config/JetBrains" "$TEMP_DIR/.config/"
cp -r "$HOME/.config/appium-inspector" "$TEMP_DIR/.config/"
# Create the squashfs backup using xz compression with maximum level
mksquashfs "$TEMP_DIR" "$BACKUP_FILE" -comp xz -Xbcj x86 -b 1M
# Remove the temporary directory
rm -rf "$TEMP_DIR"
echo "Backup created: $BACKUP_FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment