Thứ Năm, 11 tháng 1, 2018

Backup to Google Drive



git clone https://github.com/bachvtuan/Backup-To-Google-Drive.git
pip install --upgrade google-api-python-client 
pip install --upgrade oauth2client==1.5.2
pip install PyOpenSSL

  1. you create your google drive api first at Link.
  2. After google drive project is created, You go to API & Auth tab and click on Credentials. From here, click on button with label Create new Client ID and select service account and click on Create Client ID button , after created service account, you download the private key to somewhere such as I put at path "configs/74214843aee8aba9f11b7825e0a22ef1f06533b7-privatekey.p12" and copy service account id such as "xxxxx-5kfab22qfu82uub2887gi0c9e6eincmu@developer.gserviceaccount.com"
  3. You come back to your google drive drive.google.com and create share folder( you create an empty folder and right click on the folder and share to user xxxxx-5kfab22qfu82uub2887gi0c9e6eincmu@developer.gserviceaccount.com ) and copy the folder id ( You can look at the url after visit folder and the id is there ) and in my case the backup folder url is https://drive.google.com/#folders/0B0XTTQmH9aXreFdxS0txVU5Xb1U so that the id is 0B0XTTQmH9aXreFdxS0txVU5Xb1U
  4. Create config file( such as config_file.json ) and input into this file with json format such as
    {
     "service_account":"xxxxx-5kfab22qfu82uub2887gi0c9e6eincmu@developer.gserviceaccount.com",
     "private_key12_path":"configs/74214843aee8aba9f11b7825e0a22ef1f06533b7-privatekey.p12",
     "backup_folder_id":"0B0XTTQmH9aXreFdxS0txVU5Xb1U",
     "description" : "Description for backup file",
     "max_file_in_folder": 5
    }

Share This!


Không có nhận xét nào:

Đăng nhận xét