<p>We are using <a href="https://kubedb.com/docs/0.10.0/guides/redis/" rel="nofollow noreferrer">KubeDB</a> in our cluster to manage our DB's.</p>

<p>So Redis is deployed via a <a href="https://kubedb.com/docs/0.10.0/concepts/databases/redis/" rel="nofollow noreferrer">KubeDB Redis object</a> and KubeDB attaches a PVC to the Redis pod.</p>

<p>Unfortunately KubeDB doesn't support any restoring or backing up of Redis dumps (yet).</p>

<p>For the backup our solution is to have a CronJob running which copies the <code>dump.rdb</code> from the Redis pod into the job pod and then uploads it to S3.</p>

<p>For the restoring of the dump I wanted to do the same, just the other way around. Have a temporary pod which downloads the S3 backup and then copies it over to the Redis pod into the <code>dump.rdb</code> location.</p>

<p>The <code>redis.conf</code> looks like this:</p>

<pre><code>....
# The filename where to dump the DB
dbfilename dump.rdb

# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
dir /data
....
</code></pre>

<p>The copying works. The <code>dump.rdb</code> is in the correct location with the correct permissions. I verified this by starting a second redis-server in the Redis pod using the same <code>redis.conf</code>. The <code>dump.rdb</code> is being loaded into the server without a problem.</p>

<p>However, since I don't want to manually start a second redis-server, I restarted the Redis pod (by kubectl delete pods) for the pod to pickup the copied <code>dump.rdb</code>.</p>

<p>Everytime I delete the pod, the <code>dump.rdb</code> is deleted and a new <code>dump.rdb</code> is being created with a much smaller size (93 bytes).</p>

<p>I don't believe it is a PVC issue since I have created a few files to test whether they are deleted as well. They are not. Only the <code>dump.rdb</code>.</p>

<p>Why does this happen? I am expecting Redis to just restore the DB from the <code>dump.rdb</code> and not create a new one.</p>

<p>EDIT: Yeah, size of <code>dump.rdb</code> is around 47 GB. Redis version is 4.0.11.</p>

<p>Sooo, a few hours later, my teammate remembered that Redis executes a save to dump on <a href="https://redis.io/commands/shutdown" rel="noreferrer">shutdown</a>.</p>

<p>Instead of deleting the pod using <code>kubectl delete pod</code> I now changed the code to run a <code>SHUTDOWN NOSAVE</code> using the <code>redis-cli</code>.</p>

<pre><code>kubectl exec &lt;redis-pod&gt; -- /bin/bash -c 'redis-cli -a $(cat /usr/local/etc/redis/redis.conf | grep "requirepass " | sed -e "s/requirepass //g") SHUTDOWN NOSAVE'
</code></pre>
