현재 mac과 linux 를 사용하고 있습니다. 최근에서 linux 운영체계를 더 자주사용하고 있습니다. 사용하면서 blog 글을 linux 에서 작성해서 mac과 공유하는 문제가 발생했습니다.
저는 Mac에서 ㅣObsidian 을 사용해서 google drive 와 파일싱크를 통해서 저장하고 있었습니다. 그런데, linux에서는 공식적으로 지원하는 google drive앱이 없기 때문에, 3rd party앱으로 이를 해결해야 합니다.

여러가지 앱을 사용해 봤지만, 현재는 rclone 을 사용해서 해결하고 있습니다.
우선 rclone config 명령어를 통해서 웹하드를 연결해야 합니다. (구글드라이브 연결도 간단함)

rclone 을 통해서 드라이버 연결

현재는 GOOGLE DRIVE 와 DROPBOX가 연결 해놓은 상태입니다. NEW를 통해서 새로운 웹하드에 연결을 할 수 있습니다.
rclone v1.61.1 에서 지원하는 목록입니다.

$ rclone config
Current remotes:

Name                 Type
====                 ====
dropbox              dropbox
gDrive               drive

e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> n

Enter name for new remote.
name> d

Option Storage.
Type of storage to configure.
Choose a number from below, or type in your own value.
 1 / 1Fichier
   \ (fichier)
 2 / Akamai NetStorage
   \ (netstorage)
 3 / Alias for an existing remote
   \ (alias)
 4 / Amazon Drive
   \ (amazon cloud drive)
 5 / Amazon S3 Compliant Storage Providers including AWS, Alibaba, Ceph, China Mobile, Cloudflare, ArvanCloud, DigitalOcean, Dreamhost, Huawei OBS, IBM COS, IDrive e2, IONOS Cloud, Liara, Lyve Cloud, Minio, Netease, RackCorp, Scaleway, SeaweedFS, StackPath, Storj, Tencent COS, Qiniu and Wasabi
   \ (s3)
 6 / Backblaze B2
   \ (b2)
 7 / Better checksums for other remotes
   \ (hasher)
 8 / Box
   \ (box)
 9 / Cache a remote
   \ (cache)
10 / Citrix Sharefile
   \ (sharefile)
11 / Combine several remotes into one
   \ (combine)
12 / Compress a remote
   \ (compress)
13 / Dropbox
   \ (dropbox)
14 / Encrypt/Decrypt a remote
   \ (crypt)
15 / Enterprise File Fabric
   \ (filefabric)
16 / FTP
   \ (ftp)
17 / Google Cloud Storage (this is not Google Drive)
   \ (google cloud storage)
18 / Google Drive
   \ (drive)
19 / Google Photos
   \ (google photos)
20 / HTTP
   \ (http)
21 / Hadoop distributed file system
   \ (hdfs)
22 / HiDrive
   \ (hidrive)
23 / In memory object storage system.
   \ (memory)
24 / Internet Archive
   \ (internetarchive)
25 / Jottacloud
   \ (jottacloud)
26 / Koofr, Digi Storage and other Koofr-compatible storage providers
   \ (koofr)
27 / Local Disk
   \ (local)
28 / Mail.ru Cloud
   \ (mailru)
29 / Mega
   \ (mega)
30 / Microsoft Azure Blob Storage
   \ (azureblob)
31 / Microsoft OneDrive
   \ (onedrive)
32 / OpenDrive
   \ (opendrive)
33 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ (swift)
34 / Oracle Cloud Infrastructure Object Storage
   \ (oracleobjectstorage)
35 / Pcloud
   \ (pcloud)
36 / Put.io
   \ (putio)
37 / QingCloud Object Storage
   \ (qingstor)
38 / SMB / CIFS
   \ (smb)
39 / SSH/SFTP
   \ (sftp)
40 / Sia Decentralized Cloud
   \ (sia)
41 / Storj Decentralized Cloud Storage
   \ (storj)
42 / Sugarsync
   \ (sugarsync)
43 / Transparently chunk/split large files
   \ (chunker)
44 / Union merges the contents of several upstream fs
   \ (union)
45 / Uptobox
   \ (uptobox)
46 / WebDAV
   \ (webdav)
47 / Yandex Disk
   \ (yandex)
48 / Zoho
   \ (zoho)
49 / premiumize.me
   \ (premiumizeme)
50 / seafile
   \ (seafile)
Storage> ^C⏎             

웹하드를 등록하는 부분은 간단한 부분이어서 따로 설명은 안 하려고합니다.

sync 하기

웹드라이브에서 파일과 LOCAL의 폴더를 동기화하고 싶을 때 사용합니다. 필요한 경우 파일 삭제를 포함하여 소스와 일치하도록 대상을 업데이트 합니다.

동기화시 삭제가 포함되므로 데이터 손실을 방지하기 위해 항상 --dry-run 또는 --interactive/-i 프랠그를 사용하여 동기하 작업을 먼저 테스트 하는 것이 좋습니다.

`-i`: interactive 모드를 사용하면 파일이 강제적으로 수정되는 것을 막고, 확인하면서 동기화할 수 있습니다.

파일을 원본에서 복사할 곳을 잘 설정하는 것이 중요합니다
$ rclone sync -i [원본 폴더] [목적지]

# google drive -----> local
$ mkdir -p ~/gdrive/[폴더명]
$ rclone sync -i mygdrive:/[폴더명] ~/gdrive/[폴더명]

# local ------> google drive
$ rclone sync -i ~/gdrive/[폴더명] mygdrive:/[폴더명]
  • --bwlimit=8.5M: 대역폭 속도를 8.5M으로 제한하여 Google에 부과하는 일일 최대업로드 한도에 도달하지 못하도록 합니다.
  • --progress: 복제/동기화 중인 파일이 완료될 때까지 남은 시간, 복제/동기화가 전송되는 속도를 보여주는 출력 합니다.

파일 조회하기

동기화 하기 전에 해당 웹하드에 어떤파일이 들어있는지 명령어를 통해서 조회 할수 있습니다. 굳이 웹을 통해서 조회하지 않아도 바로 조회할 수 있어 편합니다.

$ rclone ls mygdrive:
$ rclone lsd mygdrive:

mount 하기

저는 실시간으로 파일을 동기화해서 사용하고 싶기 때문에 위와 같이 파일을 sync 하는 것과는 다릅니다.

$ rclone mount gDrive:source_folder target_folder --allow-other --cache-db-purge --fast-list --poll-interval 10m

systemd 구성으로 자동 mount 하기

매번 명령어를 실행해서 동작하는 것을 systemd에 등록해서 자동 mount 하려고 합니다.

/etc/systemd/system/gdrive.service 파일을 생성합니다.

[Unit]
Description=rclone for gdrive_mount
AssertPathIsDirectory=/home/leaf/target_folder
After=networking.service

[Service]
Type=simple
ExecStart=rclone mount --config=/home/leaf/.config/rclone/rclone.conf gdrive_source_folder: /home/leaf/target_folder --allow-other --cache-db-purge --fast-list --poll-interval 10m
ExecStop=/bin/fusermount -u /home/leaf/target_folder
Restart=always
RestartSec=10

[Install]
WantedBy=default.target
$ systemctl enable gdrive.service
$ systemctl start gdrive.service
반응형

+ Recent posts