Hey everyone,
I’m trying to find a way to back up my server files to Google Drive. Originally, I was going to use rclone, but it’s blocked by my organization. Now I’m looking for alternatives that work with a headless browser setup.
Does anyone know of any reliable scripts or programs that can handle this? I need something that can:
- Log into Google Drive through a headless browser
- Upload files from my server
- Work without a GUI
I’ve been searching online, but haven’t found many options that fit these requirements. Any suggestions or personal experiences would be super helpful. Thanks in advance for your input!
have u tried using google drive api directly? it’s a bit tricky to set up but works gr8 for headless uploads. u’ll need to create a service account & get credentials, then use python or nodejs to handle the uploads. no browser needed. might be worth a shot if selenium is too slow for ur needs.
I’ve encountered a similar situation before, and one approach that worked well was using Selenium with Python to automate the headless browser. I began by installing Selenium and a compatible webdriver, such as ChromeDriver, and then crafted a Python script to handle the login process for Google Drive. The script utilized Selenium’s file upload capabilities to transfer files from the server. The greatest challenge was navigating Google’s authentication process, particularly with two-factor authentication, which required careful timing and exception handling. Although this solution may be slower for large or numerous file transfers, its flexibility allows for customization based on individual needs. If you are comfortable with Python programming, this method might be a viable alternative.
For your headless Google Drive upload scenario, I’d recommend exploring the gsheet-cli tool. It’s a command-line interface for Google Sheets that can be extended to work with Google Drive. While primarily designed for spreadsheet operations, it uses OAuth2 for authentication and can be adapted for file uploads.
To set it up, you’ll need to create a Google Cloud project, enable the Drive API, and obtain OAuth credentials. The tool handles authentication securely, storing tokens locally. You can then write a simple script to automate the upload process.
This approach offers a balance between ease of use and flexibility, without the overhead of a full browser automation setup. It’s been reliable in my experience for similar server-based tasks.