diff --git a/README.md b/README.md index 5942a4f..de123c3 100755 --- a/README.md +++ b/README.md @@ -52,70 +52,6 @@ Lazywarden is a Python automation tool designed to Backup and Restore data from -## Demo Import - - - - - - - - -## Demo Schedule - - - -## Demo Import Keepass - - - - - - -## Demo Decrypting All Zip and JSON - - - - -### SMTP Backup - - - - -### SMTP Scheduled - - - -### CalDAV Backup - - - -### CalDAV Schedule - - - - -### Todoist Backup - - - -### Todoist Schedule - - - - -### Slack - - -### Discord - - -### Telegram - - - - - ## System Requirements - **Operating System**: Compatible with major Linux distributions @@ -354,312 +290,6 @@ python3 main.py ``` -## Steps to Configure Bitwarden Secrets Manager - -To set up Secret Management in Bitwarden, first create a new organization in your account to serve as a container for shared secrets. Next, subscribe to the Secret Manager service, which allows you to securely store an unlimited number of secrets, such as API keys, passwords and certificates. This service provides end-to-end encryption, centralized management and access control. - - - -- After creating your Organization, go to Secret Manager in the tab at the top right. - - - -- Then create your lazywarden Project. - - - -- After creating your lazywarden Project, you need to create the secrets that will be in the lazywarden project. Here are some examples: - - - -- With these secrets added, we can now modify our **.env** file to contain our secrets. - -``` PYTHON -# Bitwarden Secrets -BW_URL=00000000-0000-0000-0000-000000000000 -BW_USERNAME=00000000-0000-0000-0000-000000000000 -BW_PASSWORD=00000000-0000-0000-0000-000000000000 -BW_TOTP_SECRET=00000000-0000-0000-0000-000000000000 -ENCRYPTION_PASSWORD=00000000-0000-0000-0000-000000000000 -ZIP_PASSWORD=00000000-0000-0000-0000-000000000000 -ZIP_ATTACHMENT_PASSWORD=00000000-0000-0000-0000-000000000000 - -# pCloud Credentials -PCLOUD_USERNAME=00000000-0000-0000-0000-000000000000 -PCLOUD_PASSWORD=00000000-0000-0000-0000-000000000000 - -# Mega Credentials -MEGA_EMAIL=00000000-0000-0000-0000-000000000000 -MEGA_PASSWORD=00000000-0000-0000-0000-000000000000 - -# Dropbox Credentials -DROPBOX_ACCESS_TOKEN=00000000-0000-0000-0000-000000000000 -DROPBOX_REFRESH_TOKEN=00000000-0000-0000-0000-000000000000 -DROPBOX_APP_KEY=00000000-0000-0000-0000-000000000000 -DROPBOX_APP_SECRET=00000000-0000-0000-0000-000000000000 - -# Todoist Credentials -TODOIST_TOKEN=00000000-0000-0000-0000-000000000000 - -# CalDAV Credentials -CALDAV_URL=00000000-0000-0000-0000-000000000000 -CALDAV_USERNAME=00000000-0000-0000-0000-000000000000 -CALDAV_PASSWORD=00000000-0000-0000-0000-000000000000 - -# Nextcloud Credentials -NEXTCLOUD_URL=00000000-0000-0000-0000-000000000000 -NEXTCLOUD_USERNAME=00000000-0000-0000-0000-000000000000 -NEXTCLOUD_PASSWORD=00000000-0000-0000-0000-000000000000 - -# Seafile Credentials -SEAFILE_SERVER_URL=00000000-0000-0000-0000-000000000000 -SEAFILE_USERNAME=00000000-0000-0000-0000-000000000000 -SEAFILE_PASSWORD=00000000-0000-0000-0000-000000000000 - -# Filebase Credentials -FILEBASE_ACCESS_KEY=00000000-0000-0000-0000-000000000000 -FILEBASE_SECRET_KEY=00000000-0000-0000-0000-000000000000 - -# KeePass Password -KEEPASS_PASSWORD=00000000-0000-0000-0000-000000000000 - -# Storj Credentials -STORJ_ACCESS_KEY=00000000-0000-0000-0000-000000000000 -STORJ_SECRET_KEY=00000000-0000-0000-0000-000000000000 -STORJ_ENDPOINT=00000000-0000-0000-0000-000000000000 - -# R2 Credentials -R2_ACCESS_KEY_ID=00000000-0000-0000-0000-000000000000 -R2_SECRET_ACCESS_KEY=00000000-0000-0000-0000-000000000000 -R2_ENDPOINT_URL=00000000-0000-0000-0000-000000000000 - -# Vikunja Credentials -VIKUNJA_API_TOKEN=00000000-0000-0000-0000-000000000000 -VIKUNJA_URL=00000000-0000-0000-0000-000000000000 -``` - - - - - - -- If you have TOTP enabled on your Bitwarden account, put the seeds of your TOTP in the **BW_TOTP_SECRET** variable. - - - -- If you do not have TOTP enabled on your Bitwarden account, just put random characters as shown in the image below. - - - - -- Continue filling in the other variables one by one. If you do not have an account, for example for pCloud, MEGA, Filebase, Seafile, NextCloud or Dropbox fill in the variables with some random characters. For example, if you don't have a MEGA account, put the following: - - - - - -- As you can see in the images above, I don't have a MEGA account, so I used random strings. You always have to have something in the Secret Variables for the program to work. Now, the backup will only be stored locally in the chosen directory and in Google Drive, Dropbox, pCloud, NextCloud, Seafile and Filebase but not in MEGA as my account is not configured - - -- After creating all your secrets, create a Machine Account that will hold our ACCESS_TOKEN. - - - - - - - - -- Add and save the lazywarden project to your Machine Account. - - - - - -- Finally, go to Access Tokens and create one to use in our lazywarden project. - - - - -- To find the **ORGANIZATION_ID** variable for our **.env** you can get it by visiting the URL when you are in your organization or by running the following command: - -``` BASH -bw list organizations -``` - -``` BASH -ORGANIZATION_ID=212A4880-22f9-1114-b00e-12345234278ac - -ACCESS_TOKEN=0.345f5e9c-8730-4a4c-917b-b100003312356.Oj4XzcyGFF222212345kwzV:e5mC4d1111111128/3EQ== -``` - -# Attention: Security Critical Variables - - -``` BASH -### These variables contain the passwords for encrypting the backup. -### Change the passwords according to your preferences. - -#Contains the encryption password for the JSON file -ENCRYPTION_PASSWORD=p3mTd5SqDqkXQqE!Tpwv27Ecx - - -#Contains the encryption password for the first ZIP file -ZIP_PASSWORD=ZCGvq@gwS7QhV@&R3k*x*xN72anybyFHW2RWiBTr - - -# Contains the encryption password for the attached ZIP file. -# Where our files will be stored if Bitwarden Premium is enabled. -# If Bitwarden Premium is not enabled, the attachment folder will be empty. -ZIP_ATTACHMENT_PASSWORD=HBLXL9!grer@Uay2edkwTXeZx!E9DxKphNxsNak1knb3dcfx2o - -# Contains the encryption password for KeePass Database (Kdbx). -KEEPASS_PASSWORD=e2zkwTXe21!E9DxKp -``` - -## Dropbox API Configuration - -By following these steps, your Dropbox Token will remain active and will not expire every 4 hours. - -1. Go to https://www.dropbox.com/developers/apps/create - - Create a new project. - - - - - - - - -- Create Permissions - - - - -2. Obtain the Authorization Code - -- Open a browser and navigate to the following URL, replacing `` with your App Key: - -``` HTML -https://www.dropbox.com/oauth2/authorize?token_access_type=offline&response_type=code&client_id= -``` - - - - - - - - - - - - -3. Obtain the Authorization Token - -Run the following command in the terminal, making sure to replace ``, ``, and `` with the correct values: - -``` BASH -curl https://api.dropbox.com/oauth2/token \ --d code= \ --d grant_type=authorization_code \ --u : - -#Example -curl https://api.dropbox.com/oauth2/token \ --d code=G4sTbrY9DMoAAAAAAAAAQTeLtVHACmv1tVaWYLYCGvA \ --d grant_type=authorization_code \ --u 7on1ofs1236ki:b6bl6jg123lm8iz -``` - -- When you run the command, you will receive a response like this: - -``` BASH - "access_token": "sl.B3hxfHXr123459z8_TS230pcLcLNbJ1234Hj-ccZmG5XCcQrN-Wb6ESMs0PSzwOtROxLb6XRaj6mUzHU1g8G60canTvjkWBBaNzVY1234hH2FEOhlwseaNcnQ9RyPn6vh", - "token_type": "bearer", - "expires_in": 14400, - "refresh_token": "WtG6MI5YdccAAAAAAAAAAcAvu1234nB6skR3BmpgH3x5Reb-ae7FsLuNQ5-mZkk", - "scope": "account_info.read", - "uid": "143786425", - "account_id": "dbid:BBAnJyzGYtm3-WP9a2HkL1TL8FVgPl5s-VM" -``` - -- Now use this new `refresh_token`, `access_token` along with the previous ``, and `` to fill in the secret variables needed in Bitwarden Secret Manager: - -``` BASH -#Example - DROPBOX_ACCESS_TOKEN=sl.B3hxfHXrU12345z8_TS230pcLcLNbJj019MyrVHj-ccZmG5XCcQrN-Wb6ESMs0PSzwOtROxLb612345g8G60canTvjkWBBaNzVYP15cx5h12345NcnQ9RyPn6vh -      DROPBOX_REFRESH_TOKEN=WtG6MI5Yd1234AAAAAAcAvuFd9usnB6skR3BmpgH3x5Reb-ae7FsLuNQ5-mZkk -      DROPBOX_APP_KEY=1on14fs123456ki -      DROPBOX_APP_SECRET=b1bl12345m8iz - -``` - - - -## Google Drive API Configuration - -1. Go to this web page [https://console.developers.google.com/iam-admin/serviceaccounts](https://console.developers.google.com/iam-admin/serviceaccounts) -2. Create a New Project. - - - - - -3. Then go to "Service Accounts" and create a new service. - - - - - - - - -4. Select the role "Actions Admin". - - - - -5. Download the key in JSON format. This key will be used in our project to upload the Bitwarden backup to Google Drive. Once you obtain the JSON file, store it in the **/config** folder of the project. Name the JSON file **bitwarden-drive-backup-google.json**. - -``` BASH -# Place the Google credentials file in the specified path /config - -GOOGLE_SERVICE_ACCOUNT_FILE=/home/lazywarden/config/bitwarden-drive-backup-google.json - -``` - - - - - -6. Go to the following link and enable the Google Drive API:[https://console.cloud.google.com/apis/library](https://console.cloud.google.com/apis/library) - - - -7. Now that you have enabled the API, go to your Google Drive and create a folder named "Bitwarden-Backup". - - - - -8. Share the "Bitwarden-Backup" folder by clicking on "Share" and share it with the email address created in the Service Account when you set up the project. - - - - - - - -9. After sharing the folder, you need to get the ID of this folder to store it in your **.env** file. To find the ID of the “Bitwarden-Backup” folder, open the folder and look at the URL in your browser. - -``` BASH -GOOGLE_FOLDER_ID=1qtV4vfIjmXyhDdzIzJ6RiCc-b0M22vsF -``` - - - - - ### Tree Structure ``` PYTHON @@ -699,51 +329,6 @@ lazywarden/ -### Cron Job for Python (optional) - -To automatically run the backup script in the background using cron, every 24 hours follow these steps: - -1. Open the crontab for editing: - -```BASH -crontab -e -``` - -2. Select an editor if you dont have one configured: - -``` BASH - -Select an editor. To change later, run 'select-editor'. - 1. /bin/nano <---- easiest - 2. /usr/bin/vim.basic - 3. /usr/bin/vim.tiny - 4. /bin/ed -Choose 1-4 [1]: 1 - -``` - - -3. Add the following line to schedule the `lazywarden.py` script to run at midnight every day: - - -``` BASH - -0 0 23 * * /root/lazywarden/venv/bin/python3 /root/lazywarden/app/main.py >> /var/log/lazywarden-cron.log 2>&1 - -``` - - -4. Save & Close and reload the file. Verify that the cron job is set up correctly: - -``` BASH - -service cron reload - -crontab -l - -``` - - ### Docker Compose @@ -792,7 +377,7 @@ docker compose up -d ##### **Important Note** - Large attachments in your Bitwarden account (e.g., MP4 videos, MP3 files, high-resolution photos) may cause the backup process to take longer. Uploading these larger backups to cloud services will also be slower. Local storage and importing data are much faster in comparison. -- A high number of attachments can significantly extend the total backup time. Upload errors may occur when sending files to Dropbox, Google Drive, pCloud, MEGA, Seafile, Nextcloud, or Filebase. If an error occurs, retrying the backup often resolves the issue. +- A high number of attachments can significantly extend the total backup time. Upload errors may occur when sending files to Dropbox, Google Drive, pCloud, MEGA, Seafile, Nextcloud, Storj, Cloudflare R2, or Filebase. If an error occurs, retrying the backup often resolves the issue. - Configuring the Bitwarden Secret Manager is required for the program to function correctly. Even if you don't have an account, you must set a random variable to ensure proper operation. - This program is compatible with both self-hosted Bitwarden and Vaultwarden instances. - Import functionality for Vaultwarden and self-hosted Bitwarden is not yet implemented in the Bitwarden API. @@ -806,7 +391,7 @@ docker compose up -d ### Motivations -- I created Lazywarden to Automate Bitwarden Backups without manual effort or exposing sensitive data. After struggling with complex tools, I leveraged Bitwarden Secret Manager to securely manage secrets. Lazywarden automates backups and uploads them to multiple cloud services (Google Drive, Dropbox, pCloud, MEGA, Seafile, Nextcloud, Filebase), and integrates with Telegram, Discord, Slack, Todoist, and CalDAV for notifications and tracking. Its standout feature is the ability to restore encrypted backups back into Bitwarden, making backup management simple, secure, and efficient. +- I created Lazywarden to Automate Bitwarden Backups without manual effort or exposing sensitive data. After struggling with complex tools, I leveraged Bitwarden Secret Manager to securely manage secrets. Lazywarden automates backups and uploads them to multiple cloud services (Google Drive, Dropbox, pCloud, MEGA, Seafile, Nextcloud, Filebase, Storj, Cloudflare R2), and integrates with Telegram, Discord, Slack, Todoist, Vikunja, and CalDAV for notifications and tracking. Its standout feature is the ability to restore encrypted backups back into Bitwarden, making backup management simple, secure, and efficient. - If you like this project, please consider giving it a ⭐