Skip to content

Instantly share code, notes, and snippets.

@ScottJWalter
Last active January 29, 2018 18:58
Show Gist options
  • Save ScottJWalter/138399bdaac258877be25f8a65b656a7 to your computer and use it in GitHub Desktop.
Save ScottJWalter/138399bdaac258877be25f8a65b656a7 to your computer and use it in GitHub Desktop.
Using Symlinks to circumvent Google Backup and Sync issue
rem While you can specify a folder be backed up with Google's "Backup and Sync" service, you _cannot_ indicate you wish it to ignore
rem one or more subfolders. For example, if you've configured Google Backup to back up your local Github folders, it will (without the
rem trick below) also backup the hidden '.git' folder, which can easily chew up GIGs of your Google Drive. Kind of annoying.
rem
rem However, Google doesn't follow symlinks, so the best solution I've found currently is to:
rem
rem 1) MOVE (not copy) the folder you don't want backed up to a folder you're not backing up to Google (for "C:\DontBackup")
rem 2) Create a folder (directory) symlink from the old folder location to the new location
rem
rem e.g. mklink /D "C:\Users\Wallard\GitHub\My-Git-Project\.git" "C:\NoBackup\Users\Wallard\Github\My-Git-Project\.git"
rem
rem This _should_ allow the program that uses that folder to continue to function without taking up space on your Google drive. While
rem it's not necessary to clone the entire directory path in the new (non-backup) location, it doesn't hurt, as it helps you keep track
rem of where the folder came from.
rem
rem From the parent directory, containing the folder you wish Google to ignore:
rem
rem gbs-ignore.bat FOLDER_NAME
rem
set NOBACKUP_ROOT="C:\NoBackup"
setlocal enableextensions
rem Create folder path (if necessary), move folder, finally create symlink
for /f "tokens=2 delims=:" %%i in ("%cd%") do mkdir "%NOBACKUP_ROOT%\%%i" && move "%cd%\%1" "%NOBACKUP_ROOT%\%%i" && mklink /D "%cd%\%1" "%NOBACKUP_ROOT%\%%i\%1"
endlocal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment