# Google Drive - unsync uploaded files immediately after uploaded

**URL:** <https://forum.odrive.com/t/google-drive-unsync-uploaded-files-immediately-after-uploaded/8054>\
**Category:** I Have a Question\
**Created:** [November 2, 2020, 4:24pm UTC](https://forum.odrive.com/t/google-drive-unsync-uploaded-files-immediately-after-uploaded/8054 "2020-11-02T16:24:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![voarsh](https://forum.odrive.com/user_avatar/forum.odrive.com/voarsh/32/335_2.png) [@voarsh](https://forum.odrive.com/u/voarsh)\
**Post date:** [November 2, 2020, 4:24pm UTC](https://forum.odrive.com/t/google-drive-unsync-uploaded-files-immediately-after-uploaded/8054/1 "2020-11-02T16:24:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Tony](https://forum.odrive.com/user_avatar/forum.odrive.com/tony/32/19_2.png) [@Tony](https://forum.odrive.com/u/Tony)\
**Post date:** [November 3, 2020, 6:00am UTC](https://forum.odrive.com/t/google-drive-unsync-uploaded-files-immediately-after-uploaded/8054/2 "2020-11-03T06:00:00Z")

</div>

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.

> [@voarsh](#):
>
> and because oDrive is on the same destination as the image, it won’t let me do it…

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

> [@voarsh](#):
>
> uploading in chunks and syncing

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

---

<div class="post-metadata">

**Author:** ![voarsh](https://forum.odrive.com/user_avatar/forum.odrive.com/voarsh/32/335_2.png) [@voarsh](https://forum.odrive.com/u/voarsh)\
**Post date:** [November 3, 2020, 1:35pm UTC](https://forum.odrive.com/t/google-drive-unsync-uploaded-files-immediately-after-uploaded/8054/3 "2020-11-03T13:35:20Z")

</div>

> [@Tony](#):
>
> 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.

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

> [@Tony](#):
>
> > [@voarsh](#):
> >
> > and because oDrive is on the same destination as the image, it won’t let me do it…
> 
> Can you run me though what it is not letting you do and why?

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. 🙂

> [@Tony](#):
>
> > [@voarsh](#):
> >
> > uploading in chunks and syncing
> 
> Is this referring to the upload+unsync routine we are talking about above?

Yep

---

<div class="post-metadata">

**Author:** ![Tony](https://forum.odrive.com/user_avatar/forum.odrive.com/tony/32/19_2.png) [@Tony](https://forum.odrive.com/u/Tony)\
**Post date:** [November 4, 2020, 2:23am UTC](https://forum.odrive.com/t/google-drive-unsync-uploaded-files-immediately-after-uploaded/8054/4 "2020-11-04T02:23:42Z")

</div>

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](https://www.odrive.com/s/e65e47fe-d0d4-45d6-bad1-0feccc2a4e5c-5fa20ee9)

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
}
```

---

<div class="post-metadata">

**Author:** ![Tony](https://forum.odrive.com/user_avatar/forum.odrive.com/tony/32/19_2.png) [@Tony](https://forum.odrive.com/u/Tony)\
**Post date:** [November 11, 2020, 5:07pm UTC](https://forum.odrive.com/t/google-drive-unsync-uploaded-files-immediately-after-uploaded/8054/5 "2020-11-11T17:07:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![voarsh](https://forum.odrive.com/user_avatar/forum.odrive.com/voarsh/32/335_2.png) [@voarsh](https://forum.odrive.com/u/voarsh)\
**Post date:** [December 5, 2020, 2:21am UTC](https://forum.odrive.com/t/google-drive-unsync-uploaded-files-immediately-after-uploaded/8054/6 "2020-12-05T02:21:37Z")

</div>

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.
