Google Drive - unsync uploaded files immediately after uploaded

I need to backup some very large hard drives to Google Drive, however, I don’t see an option to unsync files after they’re uploaded… only after “1 day” at minimum.

Is there a workaround?
E.G. windows cli to “unsync” on command line (which will unsync uploaded files), and I can repeat this periodically?

I am also using Macrium Reflect, and because oDrive is on the same destination as the image, it won’t let me do it…
So as a dirty workaround have to connect to a network computer with oDrive… that means TRANSFERRING local network, THEN uploading from remote computer to Google Drive.

I didn’t have this problem with Mountain Duck, since it is treated as a network drive. However, it is not oDrive… still oDrive is missing this unsync after upload feature…

Another issue is that Macrium Reflect checks the available space on the drive and technically, there isn’t enough, but if I were uploading in chunks and syncing, it would be fine… any thoughts?

– EDIT
I made my local network issue a bit better. it’s no longer transferring to ANOTHER PC (11 days to transfer/backup!) , by creating a fake network drive, and making the backup there. With my pro subscription I am adding the folder to oDrive. This is becoming way too hacky.

Hi @voarsh,
We can take a look at the possibility of adding the ability to auto-unsync after upload.

In the meantime, we should be able to script something using the CLI to check the syncstate of items in a particular folder structure and unsync them if they are in a “synced” state. I’ll need to take a look at this tomorrow.

I am not familiar with Macrium Reflect, unfortunately.

Can you run me though what it is not letting you do and why?

Is this referring to the upload+unsync routine we are talking about above?

Great, on both fronts.
I am sure people would benefit from unsync after uploading a file.

Macrium realised my oDrive folder (where I was putting my backup) was on the same location as what it was backing up.
So I needed to “trick” it with a fake local network drive pointing to a folder on my system, on the same drive as what it is backing up.
Unfortunately, I couldn’t use Macrium since it created TEMP file extensions, while I removed it from the premium config (blacklist) it, oDrive wouldn’t sync the files.

I am using Acronis True Image instead and oDrive is picking up the files and uploading them. :slight_smile:

Yep

Hi @voarsh,
Here is a simple powershell script that will endlessly loop through a directory and unsync any synced files inside of it. It will download the CLI automatically if it is not in the expected path. It is a little slow, but should be sufficient for your needs. It checks the files with syncstate first, before attempting to unsync. There is a commented-out line that will forego the syncstate check and just attempt to usync any non-placeholder file (odrive will reject the command if the file is not synced), which will make it a bit faster. I opted for the extra check as the default, but you can comment-out the line with the extra check and uncomment the one without it, if you like.

You can also download it here

Usage:

./unsync_all.ps1  [-p <directory path>] [-r]
Help: Unsync files that have been uploaded for a given directory
Options:
-p -dirpath The specified path
-r -recursive Unsyncs files recursively through the specified path
-h -help Help

Press ctrl+c to exit the utility

Script:

Param(
   [parameter()][alias("p")][string]$DIRPATH,
   [parameter()][alias("r")][switch]$RECURSIVE,
   [parameter()][alias("h")][switch]$HELP
)
$O="$HOME\.odrive\common"
$UNSYNC_BIN="$o\odrive.exe"
if ($RECURSIVE) {
   $PARAM = @{Recurse = $true}
}
else {
   $PARAM = @{Recurse = $false}
}
if ($HELP) {
   echo "Usage: ./unsync_all  [-p <directory path>] [-r]"
   echo "Help: Unsync files that have been uploaded for a given directory"
   echo "Options:"
   echo "-p -dirpath The specified path"
   echo "-r -recursive Unsyncs files recursively through the specified path"
   echo "-h -help Help"
   break
}
if(!(Test-Path -Path $UNSYNC_BIN)) {
    echo "Downloading CLI binary ... "
    (New-Object System.Net.WebClient).DownloadFile("https://dl.odrive.com/odrivecli-win", "$O\oc.zip")
    $shl=new-object -com shell.application
    $shl.namespace("$O").copyhere($shl.namespace("$O\oc.zip").items(),0x10)
    del "$O\oc.zip"
    echo "Done!"
}
if (-Not ($DIRPATH)){
   echo "Invalid arguments. Please consult help for usage details (-h, -help)." 
   break
}
echo "unsyncing all synced files in $DIRPATH"
while($true) {
	# Check sync state before unsyncing (extra precaution)
	Get-ChildItem -File -Path "$DIRPATH\*" -exclude *.cloud* @PARAM | % {if ($(& "$UNSYNC_BIN" syncstate "$($_.FullName)") -eq 'Synced') {echo "Unsyncing $($_.FullName)"; & "$UNSYNC_BIN" unsync "$($_.FullName)"}}
	
	# Unsync without checking sync state
	# Get-ChildItem -File -Path "$DIRPATH\*" -exclude *.cloud* @PARAM | % { echo ""; echo "Unsyncing $($_.FullName)"; & "$UNSYNC_BIN" unsync "$($_.FullName)"}
	
	# Sleep 2 seconds, then perform another scan
	Start-Sleep -s 2
}

Hi @voarsh,
I just wanted to ping this again to make sure you saw it. Were you able to give this script a shot?

Hi Tony.
I didn’t get the chance to try this.
The method I was trying didn’t work and I just got a bigger HDD for my backups.

I don’t have a need to try it at the moment, but should I need to, I’ll refer here.

1 Like