Files suddenly deleted...?



  • I accidentally closed the terminal tab with "redis-server" running and found that to turn off the server I used the command "redis-cli shutdown" to shutdown the existing connection.

    I did that and when I ran redis-server again to restart the server I was given the default page with all of my previous settings and categories deleted. Is this normal or did I do something I wasn't supposed to?

    I am a bit irritated right now as I spent all morning configuring the settings of NodeBB



  • Bizarre... I ran redis-cli shutdown again and restarted the server and it's backup for now...


  • Community Rep

    Try not to shut redis down that way. The way redis works is by storing things in memory, and only persisting to disk once in a while (which is why it's so fast). Because of that, you can actually lose data if you shut down the redis server unexpectedly before it has a chance to write to disk.

    You can prevent accidentally closing the tab in the future by running it as a service, or in the background by entering the following command:
    redis-server&

    This will run the server in the background. You can ensure that everything is saved to disk by using the command
    redis-cli save



  • @BDHarrington7 Thanks Harrington. If I wanted to stop running it in the background how would I do that? Or should I not stop it at all? I am doing this on my local machine currently.


  • GNU/Linux Admin

    @SimonQ Without complete knowledge of your setup, we can't exactly tell why redis started with the proper database one time, and not the other time.

    I will say that Redis is designed to be running in the background, so there should be no ill effects from doing so.

    If Redis is already running in the background, you can invoke redis-cli shutdown (as far as I know), but this is not recommended. See below.

    If you're running Redis by invoking "redis-server", then it probably assumed defaults for the location of the database file, since you didn't specify a config file for it to read.

    Are you running Linux? The recommended way to start and stop redis is using service:

    # As root...
    $ service redis-server stop
    $ service redis-server start
    


  • Thanks @julian I am using a Mac at the moment to run this locally on my machine. The config you're referring to is the config.json found in the root folder?

    I can "redis-server" in the root of my nodebb project with a config.json file inside it.

    Sorry for not providing enough info, still new to this


Log in to reply
 

Suggested Topics

| |