How can you disable snapshotting on a running Redis for certain DBs? - redis

How to disable Save for some DBs and allow for the others in the Redis

You cannot. An RDB snapshot is a single file that contains the data of all dbs.
You can send a FLUSHDB on the dbs you do not want to restore after the RDB is loaded.
If you'll use a dedicated Redis process for each db you could configure each one differently with a dedicated redis.conf file, and a SAVE and BGSAVE commands will only create a snapshot of the Redis process it was issued on.

Related

Batch / offline methods of converting RESP files to Redis RDB file

Assuming we want to automate the process of creating RDB files (and don't want to use Redis server for this purpose) what options are available?
The current process involves importing (with redis-cli) a set of RESP files to a Redis server and then saving a RDB file to disk (all that in a stateless Redis container, where the RDB file is not persistent and difficult to access automatically). The imported dictionaries are too large for automated data ingestion via a remote Redis python client (we have to import from files).
If the question's restrictions are liberalized somewhat to not running a local redis-server (as opposed to no dependency on any Redis server), is becomes possible to save (or more precisely, download) a remote Redis server database to a local (client-side) RDB file by connecting from a local client (redis-cli) to a remote redis-server instance (as pointed out by Itamar Haber in a comment to this answer), like this:
redis-cli -h <REMOTE_URL> -p <REMOTE_PORT> --rdb <LOCAL_PATH>/dump.rdb
It is equally possible to use redis-cli to first ingest the data from local RESP files to a remote Redis server (in order to later re-export the data to a local RDB file, as described above).

Redis data is not persistent

I am new to using Redis and I am playing around a little bit with it. I have noticed that after a little time, let's say 10 minutes all the keys that I inserted just go away.
I just did the default installation showed in the documentation. I didn't configure anything with a redis.config. Is there any configuration that I need to do so my data can persist?
Environment
Redis Server
Redis server v=6.2.6 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=557672d61c1e18ba
Redis-cli
redis-cli 6.2.6
Ubuntu 18.08 VM.
I have also been using redisInsight to insert the keys.
there are two mechanisms for persisting the data to disk:
snapshotting
append-only file (aof)
if you want to use snapshotting, you need to add the following settings in redis.conf file
dir ./path_for_saving_snapshot
dbfilename "name_of _snapshot.rdb"
save 60 1000
with this configuration, redis will dump the data to disk every 60 seconds if at least 1,000 keys changed in that period.
if you want to use aof, you need to add the following settings in redis.conf file
appendonly yes
appendfilename "your_aof_file.aof"
appendfsync everysecond
everysecond is the default FYSNC policy. you have also other options.
You can configure your Redis instance to use either of the two mechanisms or a combination of both.

Redis persistence on master slave configuration

I have configured two slaves and one master using sentinel.
I have turned off persistence on all the servers. Now the sync happens between master and slave using BGSAVE command.
So shall i assume that though i have persistence off redis is still persisting since it created rdb file for syncing data?
I guess you just have to use replication diskless to avoid Redis using BGSAVE. In fact diskless replication use socket instead of the file to send data on their slaves
https://deepsource.io/blog/redis-diskless-replication/
regard,

Redis DB backup and restore?

Is there any reliable backup & restore method, tool, ... for Redis DB ?
been googling around couples of hours and there was nothing just copy the dump file /var/lib/redis/dump.rdb or some scripts that uses MIGRATE (idk if this even count as backup)
Ok lets say there is Redis DB (big one) and its Windows version of Redis
github.com/MicrosoftArchive/redis
so we need a copy of this DB in other branch of company that uses final Linux version of Redis, cuz windows version is outdated and its performance is not good as Linux version.
all keys and values are encrypted and stored as binary format in Redis, so is there any reliable backup & restore for Redis DB ?
There are solutions around that helps you automate this process.
Making a Redis backup is quite simple though:
Review / update your Redis configuration.
Create a snapshot for your Redis data (known as a "dump"/"rdb file").
Save the RDB file to a remote location
To create the snapshot (2) you'll need to use redis-cli SAVEor BGSAVEcommand.
You'll then need to create a little script (you can find one here) to transfer your .rdb file to a remote storage (like AWS S3).
You can then automate all of that using CRON.
Of course, you can now use services like SimpleBackups to get all of that done for you.

Configure Redis slave to stop saving data to file

Can I configure Redis slave to stop saving dumps? I have omitted all save instructions in config file but slave is still doing dumps.
So I assume you have checked in the configuration file of the slave that RDB is deactivated (all save lines commented out), and the slave has been restarted after the configuration file has been changed (so this configuration is active).
At this point the background dump operation of the slave is deactivated, but it does not prevent the slave to write a dump file. Actually, the slave has to write a dump file at startup time: this is how it retrieves the data from the master in bulk mode.
When the slave starts, it sends a SYNC request to the master:
The master starts accumulating Redis commands.
The master performs a background dump
The master sends the dump file to the slave in bulk mode
The slave reads the dump file from the master and write it to the disk
When it is complete, the slave loads the dump file from the disk
The slave starts processing Redis commands accumulated by the master
Eventually, the slave will catch up
The slave is in sync with the master
That's why you can find dump files on slave side even if RDB is deactivated for the slaves.
A good reading is http://redis.io/topics/persistence
Redis has 2 kinds of persistence, you should disable AOF too:
Append-only file
Snapshotting is not very durable. If your computer running Redis
stops, your power line fails, or you accidentally kill -9 your
instance, the latest data written on Redis will get lost. While this
may not be a big deal for some applications, there are use cases for
full durability, and in these cases Redis was not a viable option. The
append-only file is an alternative, fully-durable strategy for Redis.
It became available in version 1.1.
You can turn on the AOF in your configuration file:
appendonly yes
From now on, every time Redis receives a command that changes the
dataset (e.g. SET) it will append it to the AOF. When you restart
Redis it will re-play the AOF to rebuild the state.