<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>IT Notes - cephfs</title><link>https://it-notes.dragas.net/categories/cephfs/</link><description>Articles in category cephfs</description><atom:link href="https://it-notes.dragas.net/categories/cephfs/feed.xml" rel="self"/><language>en</language><lastBuildDate>Mon, 29 Jun 2020 05:00:53 +0000</lastBuildDate><item><title>Take automatic snapshots of cephfs file systems</title><link>https://it-notes.dragas.net/2020/06/29/create-automatic-snapshots-on-cephfs/</link><description>&lt;p&gt;&lt;img src="https://images.unsplash.com/photo-1576261240726-b4782dfcd02e?ixlib=rb-1.2.1&amp;q=80&amp;fm=jpg&amp;crop=entropy&amp;cs=tinysrgb&amp;w=2000&amp;fit=max&amp;ixid=eyJhcHBfaWQiOjExNzczfQ" alt="Take automatic snapshots of cephfs file systems"&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="https://docs.ceph.com/docs/master/cephfs/"&gt;Cephfs&lt;/a&gt; is a great tool. It enables users to store and share files while taking advantage of the granularity and performance of &lt;a href="https://ceph.io"&gt;Ceph&lt;/a&gt;. One of the reasons why I'm using it is the possibility of being used on erasure coded (slow disk) pools and cached on fast ssd disks.&lt;/p&gt;
&lt;p&gt;Big amounts of data can be stored and live snapshots can be taken so remote backups can be easily performed. Those snapshots have helped me to restore specific files or directories to specific points in time in a transparent and easy way, multiple times.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Taking a manual snapshot is easy&lt;/strong&gt;: you'll find a ".snap" hidden directory inside any directory of your (cephfs) file system. You can just "mkdir &lt;em&gt;something&lt;/em&gt;" inside the .snap directory and you'll have a full snapshot called "&lt;em&gt;something&lt;/em&gt;". To remove a snapshot, simply use the 'rmdir' command and CephFS will delete and trim the space as soon as possible.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;To be able to perform it automatically&lt;/strong&gt;, I've adaped a script called "&lt;em&gt;&lt;a href="https://github.com/nachoparker/btrfs-snp/blob/master/btrfs-snp"&gt;btrfs-snp&lt;/a&gt;&lt;/em&gt;", that I generally use to snapshot a &lt;a href="https://it-notes.dragas.net/2020/06/28/btrfs-automatic-snapshots-and-remote-backups/"&gt;BTRFS&lt;/a&gt; file system, and created &lt;em&gt;"&lt;a href="https://github.com/draga79/cephfs-snp"&gt;cephfs-snp&lt;/a&gt;".&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Using cephfs-snp is quite easy:&lt;/p&gt;
&lt;pre class="highlight"&gt;&lt;code&gt;# cephfs-snp
Usage: cephfs-snp &amp;lt;dir&amp;gt; (&amp;lt;tag&amp;gt;) (&amp;lt;limit&amp;gt;) (&amp;lt;seconds&amp;gt;)

  dir     │ create snapshot of &amp;lt;dir&amp;gt;
  tag     │ name the snapshot &amp;lt;tag&amp;gt;_&amp;lt;timestamp&amp;gt;
  limit   │ keep &amp;lt;limit&amp;gt; snapshots with this tag. 0 to disable
  seconds │ don't create snapshots before &amp;lt;seconds&amp;gt; have passed from last with this tag. 0 to disable
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can just ask to perform a snapshot or specify more options to have a more granular control of the snapshots created.&lt;/p&gt;
&lt;p&gt;It becomes quite interesting when used with cron:&lt;/p&gt;
&lt;pre class="highlight"&gt;&lt;code&gt;# cat &amp;gt; /etc/cron.hourly/cephfs-snp &amp;lt;&amp;lt;EOF
#!/bin/bash
/usr/local/sbin/$BIN /home hourly  24 3600
/usr/local/sbin/$BIN /home daily    7 86400
/usr/local/sbin/$BIN /home weekly   4 604800
/usr/local/sbin/$BIN /     weekly   4 604800
/usr/local/sbin/$BIN /home monthly 12 2592000
EOF
chmod +x /etc/cron.hourly/cephfs-snp
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;For more information, you can have a look here: &lt;a href="https://github.com/draga79/cephfs-snp"&gt;https://github.com/draga79/cephfs-snp&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Have fun!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Stefano Marinelli</dc:creator><pubDate>Mon, 29 Jun 2020 05:00:53 +0000</pubDate><guid isPermaLink="true">https://it-notes.dragas.net/2020/06/29/create-automatic-snapshots-on-cephfs/</guid><category>cephfs</category><category>backup</category><category>filesystems</category><category>proxmox</category><category>data</category><category>linux</category><category>server</category><category>snapshots</category></item></channel></rss>