google云端硬盘转存onedrive(支持超大文件)

网上有一些文件转存方法,比如google云端硬盘转存onedrive秘籍如何将 Google Drive 的档案移转到 OneDrive
前一个可以转存小文件(1G以下),后者之前好像可以,现在找不到入口了。现在要想转移大文件,应该怎么办呢?

Google现在提供了一种远程计算服务Colab,本质是一个linux系统的虚拟机,接下来我们就用它将大文件传过去。

打开colab

网址:https://colab.research.google.com
可以参考一些教程啊,这些都不是我写的:
https://www.bilibili.com/video/av415448362
https://zhuanlan.zhihu.com/p/54389036

安装onedrive

没错,我们先在虚拟机上装上onedrive。

onedrive没有linux版,需要按照这个github源码安装开源版本,但是这个作者好久没更新了,好多环境依赖版本会比较老

  1. 环境依赖(这个dmd版本是好用的,其他的好多都不能用)
!sudo apt install libcurl4-openssl-dev
!sudo apt install libsqlite3-dev

!curl -fsS https://dlang.org/install.sh | bash -s dmd-2.092.1      
  1. 检查我们需要添加的环境变量,colab中不能直接改环境变量。
!cat ~/dlang/dmd-2.092.1/activate
  1. 改环境变量:
version = "2.092.1"
import os
if 'PATH' in os.environ:
    _OLD_D_PATH=os.environ['PATH']
if 'LIBRARY_PATH' in os.environ:
    _OLD_D_LIBRARY_PATH=os.environ['LIBRARY_PATH']
else:
    _OLD_D_LIBRARY_PATH=''
if 'LD_LIBRARY_PATH' in os.environ:
    _OLD_D_LD_LIBRARY_PATH=os.environ['LD_LIBRARY_PATH']
else:
    _OLD_D_LD_LIBRARY_PATH=''
os.environ['LIBRARY_PATH']="/root/dlang/dmd-"+version+"/linux/lib64:"+_OLD_D_LIBRARY_PATH
os.environ['LD_LIBRARY_PATH']="/root/dlang/dmd-"+version+"/linux/lib64:"+_OLD_D_LD_LIBRARY_PATH
if 'PATH' in os.environ:
    _OLD_D_PATH=os.environ['PATH']
# os.environ['PS1']="(dmd-"+version+")${PS1:-}"
os.environ['PATH']="/root/dlang/dub:/root/dlang/dmd-"+version+"/linux/bin64:"+_OLD_D_PATH
os.environ['DMD']="dmd"
os.environ['DC']="dmd"

  1. 安装onedrive
!git clone https://github.com/skilion/onedrive.git
%cd onedrive
!make
!sudo make install

设置同步目录

现在还没有开始上传,我们先设置一下同步目录。

“~/.config/onedrive/config"文件中定义onedrive同步根目录。这里根目录为”/content/OneDrive"

"~/.config/onedrive/sync_list"中定义要同步的文件、目录,这里我们同步"GDrive_sync"这个目录。开启同步后,这个目录会出现在我们的onedrive根目录下。

# set sync dir
!mkdir -p /root/.config/onedrive
!touch /root/.config/onedrive/config
filename = '/root/.config/onedrive/config'
with open(filename, 'w') as file_object:
  file_object.write("# Directory where the files will be synced\n")
  file_object.write("sync_dir = \"/content/OneDrive\"\n")
  file_object.write("# Skip files and directories that match this pattern\n")
  file_object.write("skip_file = \".*|~*\"\n")

filename = '/root/.config/onedrive/sync_list'
with open(filename, 'w') as file_object:
  file_object.write("GDrive_sync") # target dir in onedrive
!mkdir -p /content/OneDrive/GDrive_sync/

检查文件内容

!cat /root/.config/onedrive/config
!cat /root/.config/onedrive/sync_list

挂载GoogleDrive

将你的googledrive挂载到colab虚拟机上。

from google.colab import drive
drive.mount('/content/gdrive')

拷贝文件

将文件拷贝到同步目录下。例如:

  1. 复制:
%cd /content/OneDrive/GDrive_sync/

!cp /content/gdrive/MyDrive/datasets/VoxCeleb2/vox2_dev_mp4_partaa /content/OneDrive/GDrive_sync/
  1. 上传整个googledrive:
drive.mount('/content/OneDrive/GDrive_sync')
  1. 或者也可以直接下载网络上的资源(网速挺快):
%cd /content/OneDrive/GDrive_sync/
!wget https://thor.robots.ox.ac.uk/~vgg/data/voxceleb/vox1a/vox2_dev_mp4_partaa # 30GB

上传

大功告成

!onedrive

注:这里需要登录onedrive账号

其他

同样,也可以将onedrive的文件同步到googledrive上。

所有代码如下:

# install dependencies
!sudo apt install libcurl4-openssl-dev
!sudo apt install libsqlite3-dev
!curl -fsS https://dlang.org/install.sh | bash -s dmd-2.092.1  

# check environ
!cat ~/dlang/dmd-2.092.1/activate

# set environ
version = "2.092.1"
import os
if 'PATH' in os.environ:
    _OLD_D_PATH=os.environ['PATH']
if 'LIBRARY_PATH' in os.environ:
    _OLD_D_LIBRARY_PATH=os.environ['LIBRARY_PATH']
else:
    _OLD_D_LIBRARY_PATH=''
if 'LD_LIBRARY_PATH' in os.environ:
    _OLD_D_LD_LIBRARY_PATH=os.environ['LD_LIBRARY_PATH']
else:
    _OLD_D_LD_LIBRARY_PATH=''
os.environ['LIBRARY_PATH']="/root/dlang/dmd-"+version+"/linux/lib64:"+_OLD_D_LIBRARY_PATH
os.environ['LD_LIBRARY_PATH']="/root/dlang/dmd-"+version+"/linux/lib64:"+_OLD_D_LD_LIBRARY_PATH
if 'PATH' in os.environ:
    _OLD_D_PATH=os.environ['PATH']
# os.environ['PS1']="(dmd-"+version+")${PS1:-}"
os.environ['PATH']="/root/dlang/dub:/root/dlang/dmd-"+version+"/linux/bin64:"+_OLD_D_PATH
os.environ['DMD']="dmd"
os.environ['DC']="dmd"


# install onedrive
!git clone https://github.com/skilion/onedrive.git
%cd onedrive
!make
!sudo make install

# set sync dir
!mkdir -p /root/.config/onedrive
!touch /root/.config/onedrive/config
filename = '/root/.config/onedrive/config'
with open(filename, 'w') as file_object:
  file_object.write("# Directory where the files will be synced\n")
  file_object.write("sync_dir = \"/content/OneDrive\"\n")
  file_object.write("# Skip files and directories that match this pattern\n")
  file_object.write("skip_file = \".*|~*\"\n")

filename = '/root/.config/onedrive/sync_list'
with open(filename, 'w') as file_object:
  file_object.write("GDrive_sync") # target dir in onedrive
!mkdir -p /content/OneDrive/GDrive_sync/

# check file 
!cat /root/.config/onedrive/config
!cat /root/.config/onedrive/sync_list

# mount googledrive
from google.colab import drive
drive.mount('/content/gdrive')

# copy file
%cd /content/OneDrive/GDrive_sync/
!cp /content/gdrive/MyDrive/datasets/VoxCeleb2/vox2_dev_mp4_partaa /content/OneDrive/GDrive_sync/

# start sync
!onedrive
  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值