Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backup Restore option in Settings under Administrator #758

Open
Megatronic79 opened this issue Sep 11, 2015 · 41 comments
Open

Backup Restore option in Settings under Administrator #758

Megatronic79 opened this issue Sep 11, 2015 · 41 comments
Labels
Feature: Planned Planned Feature
Milestone

Comments

@Megatronic79
Copy link

Backup \ export \ import options in Administrator settings page to\from tar file that can be used to re-deploy to another server with all data (including channel data)

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@Sing-Li
Copy link
Member

Sing-Li commented Sep 11, 2015

👍 @Megatronic79 is transforming Rocket.Chat into an Enterprise grade platform - one feature at a time.

@Megatronic79
Copy link
Author

haha - loving the product guys

@graywolf336
Copy link
Contributor

This will probably be pretty easy when @geekgonecrazy gets finished with his import-framework branch. 😄

@engelgabriel
Copy link
Member

Nice

@marceloschmidt
Copy link
Member

Related to #746 - download history

@elboletaire
Copy link

Isn't this also related with #332 and #992 ? at least the "restore option"

I know they are different. This is an "import" option for the proper rocketchat backup, but it could be all the same process. An import / export wrapper and libraries to export / import to different formats (rocket chat itself, slack, hipchat and so on).

For example, in my work we're currently using hipchat and having an "import from hipchat" option would make us change from hipchat to rocketchat without thinking in it.

@graywolf336
Copy link
Contributor

@elboletaire Yes, there has been some work on an import framework which will allow people to create imports for any other chat service out there. Slack one is in progress and I agree that the export should be similar for Rocket.Chat.

@elboletaire
Copy link

@elboletaire Yes, there has been some work on an import framework which will allow people to create imports for any other chat service out there. Slack one is in progress and I agree that the export should be similar for Rocket.Chat.

nice! I shall be attentive to it 😄

@wargamesqcf
Copy link

I am also wanting this feature.

@9cat
Copy link

9cat commented Sep 12, 2016

almost a year, still don't have progress?

@geekgonecrazy
Copy link
Contributor

@9cat we haven't gotten to this yet. We have some other key things we need to take care of first. But... Since Rocket.Chat is self hosted, you can back up the database at absolutely any time you want via mongo.

@dupree972
Copy link

It's very easy to script the backup and schedule via mongodump.

@lunitic
Copy link

lunitic commented Sep 12, 2016

This is my script I run from crontab once per hour

backup.sh
#!/bin/sh

daten=$(date +%y%m%d%H%M)
mongodump -o /home/user/backup/$daten

@wargamesqcf
Copy link

How can I get that to work when my mongodb is inside of a docker-compose container @lunitic ?

@geekgonecrazy
Copy link
Contributor

geekgonecrazy commented Sep 19, 2016

@wargamesqcf something like this.. docker run -it --rm --link rocketchat_mongo_1:db -v $PWD:/backup mongo mongodump -h db -o /backups/<yourfilename>

Haven't tested this, but I think will work.

@wargamesqcf
Copy link

wargamesqcf commented Sep 19, 2016

its not rocketchat_mongo_1:db its whatever your username is _mongo_1:db

Now the question comes how do I restore the backup

@geekgonecrazy
Copy link
Contributor

@wargamesqcf yeah actually I think its dependent on the name of the folder you have the docker-compose file in. I personally put mine in a folder rocketchat so mine is always prefixed with rocketchat. But if you are running it from your home folder... then yeah it'd start with your username 😄

@wargamesqcf
Copy link

yep that probably what is happening, but you should output something to /backups folder in linux right?

@geekgonecrazy
Copy link
Contributor

@wargamesqcf that command would run inside the container and put the backup inside of the /backup folder inside the container. That folder is mounted to your file system to $PWD which represents your current folder. If you wanted to dump it into a certain folder then you would change $PWD:/backups to something like /backups:/backups and then on server backups would be found in /backups

@wargamesqcf
Copy link

That worked! now how do we reserves this if/when the mongodb crashes and dies?

docker run -it --link foldername_mongo_1:db -v /backups:/backups mongo mongodump -h db -o /backups/test

@lucasvanhalst
Copy link
Contributor

lucasvanhalst commented Sep 19, 2016

I use this to backup the db with a cron job every night

#!/bin/bash
set -ex
APP_NAME="rocketchat"
TIMESTAMP=`date +%F-%H%M`
BACKUP_DIR="/var/backups/mongo"
BACKUP_PATH="$BACKUP_DIR/$APP_NAME$TIMESTAMP.tgz"
docker exec mongo mongodump --archive=/dump/archive.json
7z a -t7z -mx=4 -mfb=64 -md=32m -ms=on $BACKUP_PATH /opt/rocketchat/data/dump/archive.json
# copy over the file at $BACKUP_PATH to remote server here

Then to restore it simply

docker exec -it mongo mongorestore --gzip --archive=data/archive.json

This is assuming you placed the archive.json in /opt/rocketchat/data/dump/ (which is linked to the container's /data/dump folder)

On the subject of this issue, I don't think it is relevant to build this into the core. Backup and restore should be done on the server itself, not by the application in my opinion.

@wargamesqcf
Copy link

For me I have the docker-compose.yml in a home directory, and would just leave out the var in backup dir, that shouldn't really mess with the mongorestore right?

having the application handle the backup/restore is nice because most of those are easier for the end user.

@lucasvanhalst
Copy link
Contributor

Doesn't matter where you docker-compose file is located really. And sure, place the backups wherever you want. I'd recommend copying them over to a remote server as well in the same script.

@wargamesqcf
Copy link

100% agree, shove them into a google drive.

@wargamesqcf
Copy link

I used your bash and got this as an outpout

016-09-19T18:53:27.715+0000 Failed: open /backups/mongo/archive.json: no such file or directory

#!/bin/bash
set -ex
APP_NAME="rocketchat"
TIMESTAMP=`date +%F-%H%M`
BACKUP_DIR="/backups/mongo"
BACKUP_PATH="$BACKUP_DIR/$APP_NAME$TIMESTAMP.tgz"
docker exec username_mongo_1 mongodump --archive=/backups/mongo/archive.json
7z a -t7z -mx=4 -mfb=64 -md=32m -ms=on $BACKUP_PATH /backups/mongo/archive.json

@geekgonecrazy
Copy link
Contributor

@wargamesqcf you would have had to mounted that as a directory when you started the mongo container. This is why I suggested the additional container approach 😄 This way it mounts that directory executes and then closes.

@wargamesqcf
Copy link

I have a fundamental lack of docker knowledge.

@wargamesqcf
Copy link

@geekgonecrazy so this works on backing up the mongodb that is in a docker-compose

docker run -it --link username_mongo_1:db -v /backups:/backups mongo mongodump -h db -o /backups/test

Would this work to restore the back up files?

docker run -it --link username_mongo_1:db -v /backups:/backups mongo mongorestore -h db -o /backups/test

@paladini
Copy link

paladini commented Oct 22, 2016

I've made a small script to export / import / sync Rocket.Chat configurations between two different instances on the same machine:

https://github.com/paladini/Rocket.Chat.Export.Settings

I'm no longer using Rocket.Chat, but have developed this a month ago, so it's working fine. Hope that it can help someone or at least that someone can extend this piece of software to suit it's own needs.

@dmkjr
Copy link

dmkjr commented Jan 22, 2017

Is this still missing within Rocket Chat? Need to move servers and trying to export from Rocket.Chat.

@k0nsl
Copy link
Contributor

k0nsl commented Jan 22, 2017

Yes, @dmkjr, it is still not implemented (unfortunately).

@emexelem
Copy link

emexelem commented Feb 13, 2017

I'm trying to move a RocketChat instance running with docker compose from one server to another.
I've run a docker-compose up -d on the new server, and a mongodump / mongorestore to migrate data.
It seems the public channels and the list of users have been moved successfully but I can't see all private chats and rooms, though they are visible in /admin/rooms page. Is there a way to move this data? Found #3348 but no solution there.
It seems some settings in administration haven't been moved either (SMTP config for instance). Are they stored somewhere else?

@skral
Copy link

skral commented Feb 20, 2017

I am running into the same issue of private chats and groups not restoring properly. Am I doing something wrong? Using dump only makes sense if it provides us with a fully working backup.

@laydros
Copy link

laydros commented Oct 10, 2017

Having control over your data is a pretty big thing for open source solutions. I've seen people mention that in academics it's common for a whole team to move, so they need a way to take that history with them.

The scripts to backup the mongodb are certainly a step in the right direction, both for teams moving and to simply have a backup mechanism.

I am well aware I'm not paying for this, and I could be working on a pull request instead of posting here. But I wanted to be another voice supporting this issue.

@JSzaszvari
Copy link
Contributor

JSzaszvari commented Oct 10, 2017

really don't see the point of having something built in to the web interface to do this.

mongodb has full support for proper backups, and it's the database, not the application which is important here.

Its the same with lots of enterprise apps as well that don't have a "backup interface" - you dump the database directly, not through any way in the actual application it self.

Just another unnecessary layer of complication.

Sorry don't meant to be rude but, if you are not capable of running a single command to do a full Mongo backup, and another single command for restore - you probably shouldn't be running something like this in production.

the app (RocketChat instance) should be considered disposable. it's not important, absolutely everything that is needed end to end to bring up another instance is inside the database.

you are simply pointing it at your mongo instance, nothing special.

why have the data travel through another layer instead of taking it directly from the source. it's the only way to ensure 100% that things are done properly

@maxpen
Copy link

maxpen commented Oct 10, 2017

I want!

@JSzaszvari
Copy link
Contributor

JSzaszvari commented Oct 10, 2017

Actually, A good mainstream example to expand on the above -

https://confluence.atlassian.com/adminjiraserver073/backing-up-data-861253815.html#BackingUpData-UsingJIRA

For production use, it is strongly recommended that for regular backups, you use native database backup tools instead of JIRA's XML backup service.

All serious databases come with tools to back up and restore databases (the 'MS' in RDBMS). We strongly recommend these tools in preference to the XML backup option.

@JSzaszvari
Copy link
Contributor

JSzaszvari commented Oct 10, 2017

@maxpen > I want!

Backup:
mongodump --db rocketchat --out /var/backups/mongobackups/`date +"%m-%d-%y"

Restore:
mongorestore --db rocketchat --drop /var/backups/mongobackups/01-20-16/rocketchat/

@winks
Copy link

winks commented Jul 5, 2019

In response to the discussion above, I was also looking for a feature like this.

One point that hasn't been brought up is that I have 2 running, working instances of rocket.chat and want to compare the configs.

No, I've not yet dumped mongodb but for the same reason I don't want to compare 2 SQL dumps for diffing the config of two applications in this case I'd love to have something in the admin GUI. It's not only about backup and restore.

@reetp
Copy link

reetp commented Jul 7, 2019

In response to the discussion above, I was also looking for a feature like this.

That would go in feature requests, not here.

https://github.com/RocketChat/feature-requests

However, before you open one, consider how one Rocket GUI is going to diff options with another version? That's pretty complex and not really what Rocket is about.

You probably ought to look at using a proper Mongo DB tool outside of Rocket.

Or asking for a Utility to dump JUST the configurations (so you can compare with your diff tool), and not all the data.

@winks
Copy link

winks commented Jul 8, 2019

@reetp I think it's debatable if it's a feature request (I wouldn't open one for this) or if it's just "I could (ab)use this feature for other uses" depending how nitpicky you are ;)

Just to clarify my point: Nearly all important config data is in mongo and so it's not easily machine readable by someone who doesn't want to dig deep into the application (for example someone who just wants to run a server and put some config into a config management tool like ansible). I guess I can just do some 20 liner script that diffs the mongodump output for both servers (stripping out timestamps, sort alphabetically) and it's good enough. But that was my original point, there's no "config file" in the usual sense so I thought a dump in a semi-official format (e.g. some sort of yaml) could alleviate that.

But I'll shut up now because I'm not married to this GUI export feature and am happy with mongodump I guess.

Scarvis added a commit to sibdigital/rgrt that referenced this issue Nov 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Planned Planned Feature
Projects
None yet
Development

No branches or pull requests