Bitwarden Sync between two servers reddit / selfhosted ---------------------------------------------------------------------- Extcee · 2023-11-25 09:59 Long time lurker, first time poster.. I was looking for something that would sync my self hosted Bitwarden server account with my vault.bitwarden.com account, but couldn't find anything that would do exactly what I wanted, so I wrote the following: https://github.com/martadams89/bitwarden-sync It doesn't support Organisations or Multiple Users. It will export your source Bitwarden server records to a json - delete all records from your destination Bitwarden server, and then import the source records using the `bw` cli and then clean itself up. I also managed to get it running in a docker container and have a `docker-compose.yml` file in the repo to reference. Feel free to provide any feedback, constructive comments or PR's Thanks ---------------------------------------------------------------------- gamb1t9 · 2023-11-25 10:58 Have you looked into vaultwarden? ---------------------------------------------------------------------- Extcee · 2023-11-25 11:28 I’m using that for my self hosted bitwarden instance. ---------------------------------------------------------------------- TheLadDothCallMe · 2023-11-25 15:12 Did you even read past the first sentence? ---------------------------------------------------------------------- Exzellius2 · 2023-11-25 18:52 Might I ask why? Just curious. ---------------------------------------------------------------------- Extcee · 2023-11-25 18:55 Just if my self hosted goes down I’ve got a copy of my stuff in bitwarden.com or vice versa. I guess I like the idea of having multiple bitwardens in sync, and one of them being a SaaS hosted offering ---------------------------------------------------------------------- Exzellius2 · 2023-11-25 18:58 Allright. No use case for me. When my selfhosted solution goes down, I still have the offline vaults at my devices, that is enough for me. Nonetheless good work, looks clean. ---------------------------------------------------------------------- Gaming09 · 2023-11-25 20:13 Can you do this between 2 self hosted solutions ? ---------------------------------------------------------------------- Extcee · 2023-11-25 20:14 Sure! ---------------------------------------------------------------------- Stickus · 2023-11-25 20:15 Best call is to just regularly export your info and import at the other instance ---------------------------------------------------------------------- Extcee · 2023-11-25 20:16 That’s all this does, just on a schedule (and in a docker container if you want) ---------------------------------------------------------------------- Gaming09 · 2023-11-25 20:19 Thank you can't wait to try, been doing it manually for a year lol ---------------------------------------------------------------------- Mezutelni · 2023-11-25 22:50 While I believe that ops solution is fine, To be honest, if you already host two vaultwarden instances, it’s probably better to use database replication mechanism. Migrate your SQLite to MySQL, and setup native replication between those two ---------------------------------------------------------------------- FlorpCorp · 2023-11-25 22:59 Just keep in mind that syncing is not a backup! ---------------------------------------------------------------------- FlorpCorp · 2023-11-25 23:06 That would be much better, because as far as I understand this tool needs to decrypt your vault for it to sync items individually, while replicating the database wouldn't. Even just rsync-ing the sqlite file on a schedule would be better imo. ---------------------------------------------------------------------- YooperKirks · 2023-11-25 23:19 >NOTE: This does not currently sync Orgnisations or multiple users. Is this planned? ---------------------------------------------------------------------- Extcee · 2023-11-25 23:20 Not at the moment. If someone wants to have a stab it at though and make a PR I’m happy to review ---------------------------------------------------------------------- YooperKirks · 2023-11-25 23:30 OK, thanks. Starting reading out of curiosity but it felt like a possibility for a redundancy with my brother's place. ---------------------------------------------------------------------- d4nm3d · 2023-11-25 23:34 I've opened an issue but can we have an option to only backup and store x amount of backups? ---------------------------------------------------------------------- Extcee · 2023-11-25 23:44 It's just using `bw cli` and it looks like there's a possibility to list, and probably export and import organisations and members: ``` bw list organisations Unknown object "organisations". Allowed objects are items, folders, collections, org-collections, org-members, organizations. ``` I did briefly try exporting and Organizations but it didn't appear to work - I didn't try super hard though (my restore point is also a free Bitwarden.com account that only supports 1 org..) ---------------------------------------------------------------------- snds117 · 2023-11-25 23:46 Would this be possible to sync to services like Google Drive or iCloud Drive? ---------------------------------------------------------------------- Extcee · 2023-11-25 23:49 Nah this is just a wrapper around the bw cli commands to export from bitwarden server and import into another. Something like this https://github.com/Bruceforce/vaultwarden-backup that stores a backup in a file that you then use rclone to send of to GDrive might be what you’re after ---------------------------------------------------------------------- Extcee · 2023-11-26 00:23 For sure, exporting out the data is not ideal, nor does it include user settings (master password, 2FA methods etc) https://github.com/Bruceforce/vaultwarden-backup/ does a fine job of exporting the sqlite for use on another install.. Whilst my solution would technically work, my intention was more to sync between on-prem and Bitwarden cloud.. I use vaultwarden-backup to replicate my instances on-prem. ---------------------------------------------------------------------- Oujii · 2023-11-26 01:14 So, I have Cloudflare in front of my selfhosted BW instance, it block connections from most countries, whenever I am in a network thatis located on these countries, my apps log me out and don't load anymore. I wish they would just stop syncing and let the vaults offline instead. ---------------------------------------------------------------------- NoTransportation8854 · 2023-11-26 02:27 Been looking for something like this! ---------------------------------------------------------------------- DueYak5319 · 2023-11-26 10:11 If you need two instances that are online all the time that's the proper approach. I host vaultwarden in a docker container. I wanted to validate that I still have access to the vaults if the server goes down. I have a daily backup of the docker volume in a safe location. I took the backup, created a new docker instance of vaultwarden on a different server, pointed the volume to the files copied over from the oriignal server and started the container. As expected, everything works. Note that your certificate will likely not match, and you need to access via a http://localhost URL (you're selfhosting, you know how to do that). TL/DR: just plug the vaultwarden files into a new instance - works like a charm. ---------------------------------------------------------------------- Binou31 · 2023-11-26 19:47 I'm just don't understand why this case of sync, to get redundancy with failover or loadbalancing ? You should use database synchronization with 2 instances of bitwarden/vautwarden and sticky session to reach the web interface. What's happen between deletion and importation for sync ? .. the app is totally break ... ---------------------------------------------------------------------- Extcee · 2023-11-26 19:53 I totally use DB Sync on my self-hosted vaultwarden instances. This method just allows me to store a copy of my vault in the vault.bitwarden.com service also. That was my primary motivation. The deletion on destination (vault.bitwarden.com) was because I couldn’t find a way to only import new/changed records because the IDs change and I couldn’t find another way to do it (for now) ---------------------------------------------------------------------- Binou31 · 2023-11-26 20:10 I don't understand even less the goal of the sync. Why do you export/import your self hosted bitwarden on the SaaS software maintained by other ? To avoid public exposition of your self hosted solution on the web ? ---------------------------------------------------------------------- Extcee · 2023-11-26 20:18 My goal was that if all my self hosted vaults imploded, my backups fell over and I got logged out of all my devices and my sync’s vaults were gone - I can go to vault.bitwarden.com and get my passwords. It probably could work for someone in a scenario where the vault isn’t exposed externally too and you need to get some info in a pinch from a SaaS service, but this wasn’t my motivation. It’s probably unnecessary and not the most efficient solution either but I just liked the idea of syncing my on prem to cloud, and I couldn’t quite find anything that worked, so I threw something together. ---------------------------------------------------------------------- stoopiit · 2023-12-09 06:45 I've always heard this, but I don't really understand it. What am I supposed to do otherwise? Syncing it to another machine is a backup when I sync my photos to google drive or backblaze, right? What does this mean?