كيف يمكنني تحميل تلقائيا النسخ الاحتياطي من مستندات جوجل جداول البيانات ؟

StackOverflow https://stackoverflow.com//questions/9676666

سؤال

أنا حاليا باستخدام Google شكل للسماح للناس أن تقدم المعلومات التي يتم تخزينها في محرر مستندات Google وجداول البيانات.كنت أتساءل إذا كان من الممكن لأتمتة نسخة احتياطية من البيانات على فترات منتظمة.على سبيل المثال, كل يوم جمعة جدول البيانات سيتم تصديرها كما CSV و إما عبر البريد الالكتروني لي أو تخزينها في دليل محمية بكلمة مرور على الملقم.

شكرا على القراءة ، أي الأفكار هي موضع تقدير!

هل كانت مفيدة؟

المحلول

محرر مستندات جوجل هو أداة مثالية لتحرير والتعاون على المستندات الخاصة بك على الانترنت.على الرغم من أن مستندات جوجل لا توفر ميزة النسخ الاحتياطي تلقائيا ، الناس أن استخدام Dropbox للتخزين في نفس الوقت مثل محرر مستندات جوجل لديها حل لذلك.

الحل هو cloudHQ (10$+/م) الخدمة التي توفر في الوقت الحقيقي التزامن بين مستندات جوجل و دروببوإكس.على سبيل المثال ، في حين أن المستخدم هو تحرير بعض مستندات جوجل ويب مستند المستند تلقائيا تعديل في المربع المنسدل.وهذا يعني ، cloudHQ تلقائيا نسخ ملف من مستندات جوجل إلى دروببوإكس.

أود أن أقترح الرابط التالي cloudHQ جولة سريعة. CloudHQ كما يوفر جوجل كروم التمديد.مع cloudHQ تمديد متصفح كروم يمكنك مزامنة أو تكرار أي شيء في دروببوإكس الخاص بك أو القاعده حساب محرر مستندات Google - مباشرة من محرر مستندات جوجل واجهة.التمديد هو متوفر في Google Chrome الإلكتروني.

وسأكون ممتنا إذا كان أي شخص يمكن أن توفر لي بعض نصيحة أو رأي حول مزامنة البيانات بين الخدمات السحابية.

نصائح أخرى

هنا هو الحل:

  • إنشاء نسخ احتياطية تلقائيا من جوجل جداول البيانات (يوميا / أسبوعيا.... الخ)
  • كملف Excel (XLSX) في مجلد Google Drive
  • والتي يمكنك ثم تكوين المزامنة تلقائيا إلى جهاز الكمبيوتر الخاص بك

الخطوة 1

إنشاء مجلد ملفات النسخ الاحتياطي في محرك جوجل الخاص بك (على سبيل المثال"ملفاتي > المستندات > النسخ الاحتياطي").فتحه في المتصفح الخاص بك ، وجعل علما "معرف المجلد"من URL.على سبيل المثال, المجلد ID من الرابط التالي سيكون 1234abcdefgh_98765ijklmnopqrs_0XY

https://drive.google.com/drive/u/0/folders/1234abcdefgh_98765ijklmnopqrs_0XY?ths=true

الخطوة 2

فتح جدول بيانات جوجل كنت ترغب في النسخ الاحتياطي تلقائيا.من القائمة العلوية اختر "أدوات" > "محرر البرامج النصية".في النافذة الجديدة التي تفتح استبدال الرمز الافتراضي مع رمز أدناه ، تأكد من أن:

  • تمكين متقدمة خدمة السيارة إذا لم تكن بالفعل:من القائمة العلوية اختر "الموارد" > "خيارات متقدمة خدمات جوجل..." > "حملة API" > تبديل "على"
  • تحديث معرف المجلد, ، عن طريق استبدال xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx مع النسخ الاحتياطي الخاص بك معرف المجلد, في خط مع var backupFolder = ...
// function to backup the current Spreadsheet as an Excel file (XLSX) in a given folder
// -- requires "Advanced Drive Service" which must be enabled in "Resources" > "Advanced Google services..." > "Drive API" > toggle "ON"
function backupSheet() {
  // UPDATE THE FOLDER ID for e.g. "My Drive > Docs > Backups"
  var backupFolder = DriveApp.getFolderById("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var spreadsheetId = spreadsheet.getId();
  var file = Drive.Files.get(spreadsheetId);
  var url = file.exportLinks[MimeType.MICROSOFT_EXCEL];
  var token = ScriptApp.getOAuthToken();
  var options = { headers: { Authorization: "Bearer " + token } };
  var response = UrlFetchApp.fetch(url, options);
  var doc = response.getBlob();
  var backupDate = Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd' 'HH-mm-ss");
  var backupName = spreadsheet.getName() + ".backup " + backupDate + ".xlsx";
  var tempFile = DriveApp.createFile(doc).setName(backupName);
  tempFile.makeCopy(backupName, backupFolder);
  tempFile.setTrashed(true);
}

إذا كنت ترغب في اختبار البرنامج النصي انقر على "تشغيل"أيقونة فوق رمز.هذا سوف إنشاء نسخة احتياطية ملف Excel من جدول البيانات الخاص بك في مجلد النسخ الاحتياطي تكوين (بناء على معرف المجلد المذكور سابقا).

الخطوة 3

حفظ البرنامج النصي الخاص بك (من القائمة العلوية اختر "ملف" > "حفظ") ثم انقر على "المشغلات"أيقونة فوق رمز (عقارب الساعة على شكل رمز).في النافذة الجديدة التي تفتح ، انقر على "+ إضافة الزناد"(في الزاوية السفلية اليمنى).يجب أن تشاهد تراكب بعنوان "إضافة الزناد عن backupSheet" ، حيث يمكنك خطة التنفيذ الخاصة بك النسخ الاحتياطي التلقائي.على سبيل المثال, إذا كنت تريد تشغيل كل أسبوع يوم الاثنين ، يجب تكوين هذه الإعدادات:

  • اختيار أي وظيفة لتشغيل: backupSheet
  • اختيار النشر يجب تشغيل: رئيس
  • حدد مصدر الحدث: الوقت يحركها
  • حدد نوع من الزناد: الأسبوع الموقت
  • تحديد يوم في الأسبوع: كل الاثنين

حفظ الزناد عند الانتهاء من تكوين ذلك.Excel النسخ الاحتياطي الآن تلقائيا سيتم إنشاؤها في المجلد المطلوب من Google Drive.

الخطوة 4

أخيرا, تثبيت النسخ الاحتياطي و مزامنة من جوجل على جهاز الكمبيوتر الخاص بك (إذا كنت لم تقم بذلك بالفعل) ، تكوين مزامنة مجلد النسخ الاحتياطي من حساب Google Drive الخاص بك - في "تفضيلات" > "Google Drive" > تمكين "مزامنة ملفاتي إلى هذا الكمبيوتر" ، تأكد من مجلد النسخ الاحتياطي بين المجلدات مزامنتها.

التطبيق الآن سوف تلقائيا تحميل Excel نسخ احتياطية من جوجل جداول البيانات الخاصة بك دون اتصال المتعة!

Two solutions that don't involve a for-pay subscription: 1) write a script or short app (pick your language) that exports a Google Sheet using the Google Drive API as CSV. Why the Drive API? The Sheets API is for spreadsheet-oriented functionality, i.e., data formatting, column resize, creating charts, cell validation, etc., while the Drive API is for file-oriented functionality, i.e., import/export.

If you do Python, here's a complete example which you can run as a cron job on your server or if app-hosting on Google App Engine. If you don't, you can use it as pseudocode and pick any language supported by the Google APIs Client Libraries. Here's core piece of code from that example (assume the most current Sheet named 'inventory'):

FILENAME = 'inventory'
SRC_MIMETYPE = 'application/vnd.google-apps.spreadsheet'
DST_MIMETYPE = 'text/csv'

files = DRIVE.files().list(
    q='name="%s" and mimeType="%s"' % (FILENAME, SRC_MIMETYPE),
    orderBy='modifiedTime desc,name').execute().get('files', [])

if files:
    fn = '%s.csv' % os.path.splitext(files[0]['name'].replace(' ', '_'))[0]
    print('Exporting "%s" as "%s"... ' % (files[0]['name'], fn), end='')
    data = DRIVE.files().export(fileId=files[0]['id'], mimeType=DST_MIMETYPE).execute()
    if data:
        with open(fn, 'wb') as f:
            f.write(data)
        print('DONE')

If your Sheet is large, you may have to export it in chunks -- see this page on how to do that. You can also email the file contents to yourself with the Gmail API. If you're generally new to Google APIs, I have a (somewhat dated but) user-friendly intro video for you. (There are 2 videos after that maybe useful too.)

2) The other solution is for those who are "allergic" to using APIs, and that alternative is Google Apps Script, Javascript outside of the browser. Like Node, it runs server-side but on Google's servers. With Apps Script, you can use DriveApp or the advanced Drive service to access your Sheet, then use MailApp or GmailApp to email it to yourself, or use the UrlFetch service to send it to some server of your choosing. To run it at a normal interval, you'll need to create a script as a time-driven installable trigger. In either case, you don't need to host+execute your app yourself.

ps. The latest Drive API version is v3, but if you access Drive from Apps Script, it uses v2 (not deprecated yet).

Google docs is a free tool that allows users to automatically save and collaborate any data in real-time. It does not however have a built-in feature for secure google docs backup nor automatic real-time backup.

Google have stated officially in their terms of service that:

Google, and Google’s suppliers and distributors, will not be responsible for lost profits, revenues, or data, financial losses or indirect, special, consequential, exemplary, or punitive damages.

Their waving of liability is applicable not just for personal use but also business use:

If you are using our Services on behalf of a business, that business accepts these terms. It will hold harmless and indemnify Google and its affiliates… including any liability or expense arising from claims, losses, damages, suits, judgments, litigation costs and attorneys’ fees.

Today there are other options other than paying to sync to Dropbox for google docs backup automation. Your decision on how to automate your google docs backup depends on a few factors:

  1. How sensitive your data is, and whether it’s for personal or business use i.e- How liable you’ll need to be in case of data loss or a security breach.

  2. Whether you have the dev knowledge to code a script or app using any of the methods outlined by wescpy previously in full detail:

a) using the Google drive API that exports google sheets automatically b) using Python to run a cron job on your server to export a google sheet spreadsheet as CSV or c) write a non-API Javascript that runs outside your browser using the Google apps script

If you require full security and data protection, and opt for a no-pay subscription- automated google docs backup solution, suffice to say you need to be sure your code is reliable and provides the security/encryption your project requires.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top