# 👨‍💻 > [!NOTE]- > This is my backup file that I run once a week on my computer. Can you read this and detail to me as a list what this script all does exactly as you understand it? > > There is a couple of things I want to add to this script as well once we're on the same page. # 🤖 This is a robust Bash script designed for a highly customized backup and system maintenance routine. Since it runs on your **Linux Mint** primary machine, it leverages standard tools like `tar`, `rsync`, and `aptitude` to manage your **Obsidian** vaults and system configurations. Here is the step-by-step breakdown of what the script does: ### 1. Environment Setup - **Variable Initialization**: Sets up paths for your Obsidian vaults (`/media/wm/Birch/Church/Obsidian`), GitHub local repository, and backup storage. - **Date Stamping**: Generates variables for the current date (e.g., `20260316`) to keep backup folders organized. - **Directory Creation**: Creates a new backup folder for the day within your `UnArchives` directory. ### 2. The Core Backup Function (`backup_dir`) For every directory listed in your `DIRS` array (such as **CPB**, **Webflicks**, and **Writing**), the script: - **Compresses the Vault**: Creates a `.tar.gz` archive of the vault content while excluding the `.trash` and `.obsidian` (config) folders. - **Trash Preservation**: Separately archives the `.trash` folder so deleted notes aren't lost but remain outside the main backup. - **Plugin Auditing**: Generates a Markdown list of your installed **Obsidian plugins** and copies it to your GitHub directory for tracking. - **Config Backup**: Copies the entire `.obsidian` configuration folder (including themes and workspace settings) to your GitHub folder. - **Cleanup**: Deletes the original `.trash` folder from the live vault to save space. ### 3. File Synchronization (rsync) - **Temporary Notes**: Syncs specific "tmp" folders from your **CPB** (Commonplace Book) vault into a `cpb_tmp` folder in your GitHub directory. - **Mirroring**: Performs a full `rsync` of the **CPB** vault to a local GitHub-linked directory (`commn.place`), effectively preparing it for a potential git push. - **Attachment Management**: Moves attachments from the `9 meta/att/` folder to a specific external attachment directory and then removes the original metadata folder. ### 4. System Configuration Backups The script copies configuration files and snippets from several applications to your GitHub folder, including: - **Albert** (Launcher) - **Espanso** (Text expander) - **CopyQ** (Clipboard manager, excluding the heavy clipboard data file) - **Todoist** local data and **NounProject** assets ### 5. System Maintenance - **Automated Updates**: After the backups are finished, it runs a full system maintenance sequence using `aptitude`. - It updates the package list, performs a full upgrade of the OS, cleans up old package files, and removes unnecessary dependencies. # 👨‍💻 > [!NOTE]- > Alright well I need to do the same quirky backups for a new vault called `dev` located in the same directory as all the other vaults. > > I'm fairly certain there needs to be some updates made to the script regarding the "tmp" directories. What these are are directories for the Obsidian Core Plugin Templates and the Community Plugin Templater. These directories are located here from CPB's vault root: > > Templates > `9 meta/-tmp/` > > Templater > `9 meta/--tmp/` > > I want to update where these backups get put inside the local GitHub directory because I want to also put backups for this new vault in here too. > > The GitHub root directory current has these directories. > > `$tmp` > `$tmp` > `-tmp` > `--tmp` > > The ones starting with hyphens are current CPB templates as mentioned above. The ones starting with `
are legacy templates. I'm going to add them to their own sub directory and I would like to have the script add all future template backups to be put under a `/cpb` subdirectory > > `"${GITHUB_DIR}/cpb_tmp/CPB/"` > > The new vault I would like to back the same quirky way (`dev`) i mean that in this way: > > I want to backup it's own templates in the `cpb_tmp` local GitHub under it's own sub directory called `dev` > > This means that Repo will have these directories now > > - cpb > - dev > - legacy (i'll made this and move `$tmp` `$tmp` here) > > Templates would be backed up here: > > - `cpb/-tmp` & `cpb/--tmp` > - `dev/-tmp` & `dev/--tmp` > > There are a couple misc directories I don't need backed up anymore so I currently have it looking like this > > ``` > MISC_DIRS=("/home/wm/.config/albert" "/home/wm/.config/espanso/" "/home/wm/.config/albert/snippets" "/home/wm/.icons-c") > ``` > > I do also want to add these to the misc backups however and moved to the t1 local GitHub the same way the others are > > ``` > ~/.bashrc > ~/.bash_aliases > ~/.config/user-dirs.dirs > ~/.config/user-dirs.locale > ``` > > Lastly the local GitHub folders for the new `dev` vault for the cpb-like backups are: > > `/media/wm/Birch/Church/GitHub/wmprkr.dev` > `/media/wm/Birch/Church/GitHub/att-dev` > > Alright I think that's it. Please let me know if we're clear on everything before we proceed. > > --- > > Great call on the dev templates. They are actually located interally in the vault at > > `zxc/-tmp` > `zxc/--tmp` > > I would not have caught that, thank you. > > Regarding the legacy templates. The reality is I just renamed the directories in CPB back in the day from `
to `-` at the beginning so that's why both are there. Dollar sign templates are basically just pre-2023. There will not be more of them and I have already created and moved them to the legacy folder as mentioned earlier. > > Thanks for this clarification. We all good on other fronts to proceed or are there any other topics we should examine first? # 🤖 I’ve reviewed the updates you want to make, and the logic is clear. You are moving toward a more structured "templates" repository and integrating your new **dev** vault into the same "quirky" backup workflow you use for **CPB**. To confirm we are on the same page, here is the plan for the updated script: ### 1. Vault Expansion - The `dev` vault is already in your `DIRS` array, so the core `backup_dir` function will automatically handle its `.tar.gz` archiving, plugin list generation, and `.obsidian` config backup. ### 2. Template Directory Restructuring We will update the `rsync` section to reflect your new organizational structure under `${GITHUB_DIR}/cpb_tmp/`: - **Legacy**: I will add a command to sync the `
and `$` templates into `${GITHUB_DIR}/cpb_tmp/legacy/`. - **CPB**: The `-tmp` and `--tmp` folders from the **CPB** vault will now be routed to `${GITHUB_DIR}/cpb_tmp/cpb/`. - **Dev**: The script will now look for `-tmp` and `--tmp` within the **dev** vault and sync them to `${GITHUB_DIR}/cpb_tmp/dev/`. ### 3. Misc Directories & Dotfiles - **Cleanup**: I will remove the **Todoist** and **NounProject** paths from your `MISC_DIRS` list. - **Additions**: I will add your `.bashrc`, `.bash_aliases`, and the `user-dirs` configuration files to the backup loop to ensure they are copied to your GitHub `t1/Configuration files` folder. ### 4. New Vault-Specific Syncing Similar to how you mirror **CPB** to `commn.place`, I will add logic to: - Mirror the **dev** vault to `/media/wm/Birch/Church/GitHub/wmprkr.dev`. - Handle attachment syncing for the **dev** vault into the `/media/wm/Birch/Church/GitHub/att-dev` directory. --- **One quick question for clarity:** In the **CPB** vault, your templates are located at `9 meta/-tmp` and `9 meta/--tmp`. Should I assume the **dev** vault follows this exact same folder structure (`9 meta/`) for its templates as well? Once you confirm that, I can provide the updated script for you. --- # 👨‍💻 > [!NOTE]- > Great call on the dev templates. They are actually located interally in the vault at > > `zxc/-tmp` > `zxc/--tmp` > > I would not have caught that, thank you. > > Regarding the legacy templates. The reality is I just renamed the directories in CPB back in the day from $ to - at the beginning so that's why both are there. Dollar sign templates are basically just pre-2023. There will not be more of them and I have already created and moved them to the legacy folder as mentioned earlier. > > Thanks for this clarification. We all good on other fronts to proceed or are there any other topics we should examine first? # 🤖 I think we are fully synced up. Since the legacy templates are already moved, I will remove the logic that handles the old `
and `$` directories to keep your script clean and focused on your current workflow. I've updated the script to handle the new `zxc/` path for the **dev** vault templates, integrated your new dotfiles (like `.bashrc`), and set up the specific GitHub mirroring for your web project. Shell ``` #!/bin/bash # Variables BASE_DIR="/media/wm/Birch/Church/Obsidian" GITHUB_DIR="/media/wm/Birch/Church/GitHub" BACKUP_BASE_DIR="/media/wm/Birch/wn/UnArchives/OBS-backups" DATE=$(date +%Y%m%d) SHORT_DATE=$(date +%m%d) EXCLUDE_OPTS="--exclude={.trash,.obsidian}" DIRS=("CPB" "Meta" "Webflicks" "Writing" "commonplaceLabs" "QoTD" "Antiquity" "dev" "OldWP") MISC_DIRS=( "/home/wm/.config/albert" "/home/wm/.config/espanso/" "/home/wm/.config/albert/snippets" "/home/wm/.icons-c" "/home/wm/.bashrc" "/home/wm/.bash_aliases" "/home/wm/.config/user-dirs.dirs" "/home/wm/.config/user-dirs.locale" ) # Create backup directory BACKUP_DIR="${BACKUP_BASE_DIR}/${SHORT_DATE}" mkdir -p "$BACKUP_DIR" backup_dir() { local dir=$1 echo "Backing up $dir..." tar -cvf "${BACKUP_DIR}/${DATE}_${dir}.tar.gz" $EXCLUDE_OPTS "${BASE_DIR}/${dir}/" tar -cvf "${BACKUP_DIR}/${DATE}_${dir}-trash.tar.gz" "${BASE_DIR}/${dir}/.trash" ls "${BASE_DIR}/${dir}/.obsidian/plugins" |& tee -a "${BACKUP_DIR}/${DATE}_${dir}-pluginList.md" cp "${BACKUP_DIR}/${DATE}_${dir}-pluginList.md" "${GITHUB_DIR}/obsBackups/plugins-${dir}.md" cp -r "${BASE_DIR}/${dir}/.obsidian" "${GITHUB_DIR}/obsBackups/${dir}" rm -R "${BASE_DIR}/${dir}/.trash" } # Backup all directories for dir in "${DIRS[@]}"; do backup_dir "$dir" done # --- Template Backups (The "Quirky" Way) --- echo "Syncing CPB templates..." mkdir -p "${GITHUB_DIR}/cpb_tmp/cpb" rsync -av "${BASE_DIR}/CPB/9 meta/-tmp/" "${GITHUB_DIR}/cpb_tmp/cpb/-tmp/" rsync -av "${BASE_DIR}/CPB/9 meta/--tmp/" "${GITHUB_DIR}/cpb_tmp/cpb/--tmp/" echo "Syncing dev templates..." mkdir -p "${GITHUB_DIR}/cpb_tmp/dev" rsync -av "${BASE_DIR}/dev/zxc/-tmp/" "${GITHUB_DIR}/cpb_tmp/dev/-tmp/" rsync -av "${BASE_DIR}/dev/zxc/--tmp/" "${GITHUB_DIR}/cpb_tmp/dev/--tmp/" # --- Misc & Dotfile backups --- echo "Backing up miscellaneous and config files..." for misc_dir in "${MISC_DIRS[@]}"; do cp -u -r "$misc_dir" "${GITHUB_DIR}/t1/Configuration files" done # --- CPB specific rsync operations --- echo "Running commonplace specific backups..." ls "${BASE_DIR}/CPB/.obsidian/plugins" |& tee -a "${GITHUB_DIR}/commn.place/plugins.md" rsync -av "${BASE_DIR}/CPB/" "${GITHUB_DIR}/commn.place/cpb/" rsync -av "${GITHUB_DIR}/commn.place/cpb/9 meta/att/" "${GITHUB_DIR}/att/att/" rm -r "${GITHUB_DIR}/commn.place/cpb/9 meta/att" # --- Dev specific rsync operations --- echo "Running dev specific backups..." rsync -av "${BASE_DIR}/dev/" "${GITHUB_DIR}/wmprkr.dev/" rsync -av "${GITHUB_DIR}/wmprkr.dev/zxc/att/" "${GITHUB_DIR}/att-dev/att/" # Note: Assuming you want to remove the local att folder in dev mirror like you do in CPB rm -r "${GITHUB_DIR}/wmprkr.dev/zxc/att" # --- CopyQ backup --- echo "Backing up CopyQ configuration..." rsync -av --exclude='copyq_tab_JmNsaXBib2FyZA==.dat' /home/wm/.config/copyq "${GITHUB_DIR}/t1/Configuration files" # Weekly updates echo "Running system updates..." sudo aptitude update && sudo aptitude full-upgrade -y && sudo aptitude autoclean && sudo apt autoremove echo "Backup and update process completed successfully! Files are stored in ${BACKUP_DIR}" ``` ### Notable Changes - **Templates**: Organized the `rsync` logic so **CPB** templates go to `cpb_tmp/cpb` and **dev** templates (from `zxc/`) go to `cpb_tmp/dev`. - **Dotfiles**: Added your `.bashrc`, aliases, and user-dirs to the `MISC_DIRS` array. - **Mirroring**: Added the full mirror and attachment move for `wmprkr.dev` and `att-dev`. - **Cleanup**: Removed the **Todoist**, **NounProject**, and legacy `
template lines. Would you like me to help you set up a cron job so this runs automatically every Monday, or are you happy running it manually? # 👨‍💻 > [!NOTE]- > Thank you. Running it manually brings great peace of mind. # 🤖 I completely understand that. There is something satisfying about watching the terminal scroll through the `rsync` logs and knowing exactly when your data is safe and your system is clean—especially when you're managing a complex PKM setup like yours. Since you are running this manually, you might occasionally see `rsync` or `cp` throw a minor warning if a file is busy. Because you use **Obsidian** daily, just a quick reminder to close it before firing off the script to ensure the `.obsidian` workspace files and SQLite databases (if you use plugins that rely on them) are captured in a "quiet" state. It looks like your **Monday** routine is now fully equipped to handle both your long-standing **CPB** vault and your new **dev** projects. Is there anything else you’d like to tweak with the script, or perhaps a specific CSS issue on your blog you’re looking to tackle next? # 👨‍💻 > [!NOTE]- > Thank you it worked great. If I have any changes I'll be sure to report back. Thank you very much. o7 # 🤖 You’re very welcome! I’m glad the updated script is working smoothly for you. It’s a solid setup you’ve got there—especially with the added peace of mind of managing it manually on your Linux Mint machine. I'll be here whenever you're ready to tweak the script further, dive into some more CSS for the blog, or if you just need a hand with another Obsidian project. Enjoy the rest of your Caturday (or Monday, in this case)! o7 **Would you like me to help you create a specific "dry run" version of this script so you can test future changes without actually moving files?**