LoginSignup
4
4

More than 5 years have passed since last update.

特定のディレクトリを圧縮してGoogleDriveにうpしたい?

Posted at

簡単にプロジェクトを丸ごと圧縮してGoogleDriveにバックアップしたい事

そんな事、ありますよね?
え?ない?
まぁgithubとか使えばいいんだけど、もっと手軽ということで。

GoogleDriveをコマンドラインから使う為の、
https://github.com/prasmussen/gdrive
を使って、こんなのを作って使っています。

gbackup.sh
#!/bin/bash
readonly TARGET=$1

#タイムスタンプ
TIMESTAMP=`date '+%Y%m%d_%H%M%S'`

#make zipfile
zipFileName="${TARGET}_${TIMESTAMP}.zip"
zipcmd="zip ${zipFileName} -r ${TARGET}"
eval $zipcmd

##pload to GoogleDrive
eval "gdrive upload -p id_of_desitination_dir ${zipFileName}"

gbackup.sh targetDir
とすると、
targetDirをzip圧縮して
targetDir_20170508_164637
のようにファイル名にタイムスタンプを付け、自動でGoogleDriveにupします。
特定のディレクトリをスナップショット的に保存するのに使っています。

設定

最終行の
id_of_desitination_dir
をバックアップを保存したいGoogleDrive上のフォルダのIDに置き換えてください。
IDはそのディレクトリ内をブラウザで表示した時のURL
https://drive.google.com/drive/u/0/folders/xxxxxxxxxxxx
の最後尾のxxxxxxxxxxxxです。

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4