How to shutdown redis safely without data loss?

by tressie.damore , in category: Third Party Scripts , 18 days ago

How to shutdown redis safely without data loss?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer


by kadin , 17 days ago


To shutdown Redis safely without data loss, you can follow these steps:

  1. Save the data to disk: Before shutting down Redis, you should make sure that all data is saved to disk using the BGSAVE command. This will create a snapshot of the current data in the background.
redis-cli bgsave

  1. Check the status of the saving process: You can check the status of the saving process using the INFO persistence command. Wait for the saving process to complete before proceeding to the next step.
redis-cli INFO persistence

  1. Shutdown Redis: Once the saving process is complete, you can safely shutdown Redis using the SHUTDOWN command. This will gracefully stop the Redis server without losing any data.
redis-cli SHUTDOWN

Following these steps will ensure that your data is safely saved to disk before shutting down Redis, preventing any data loss.