Skip to content

Commit

Permalink
New html for modified nextcloud.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
fazlerabbi37 committed Oct 15, 2018
1 parent 824cca9 commit 1ff1b34
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 29 deletions.
1 change: 1 addition & 0 deletions docs/_sources/gitea.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ Add the following at the bottom::
RENDER_COMMAND = "rst2html.py --no-raw"
IS_INPUT_FILE = false

Now save the file and restart the gitea service.

Source
------
Expand Down
48 changes: 34 additions & 14 deletions docs/_sources/nextcloud.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -172,27 +172,46 @@ Turn on maintenance mode

sudo -u www-data php $path/to/webserver/document-root/nextcloud/occ maintenance:mode --on

Make a backup directory
```````````````````````
We will make a temporery backup directory where we will story the backup files and directorys until we make a single ``.tar`` archive from them.::

mkdir $path/of/backup/nextcloud_`date +"%d-%b-%Y"`

Backup folders
``````````````
Simply copy config, data and theme folders (or even our whole Nextcloud install and data folder) to a place outside of our Nextcloud environment. We can use this command::

sudo rsync -Aax $path/to/webserver/document-root/nextcloud/ $path/of/backup/nextcloud_`date +"%d-%b-%Y"`/
sudo rsync -Aax $path/to/webserver/document-root/nextcloud/ $path/of/backup/nextcloud_`date +"%d-%b-%Y"`/nextcloud_directory_backup_`date +"%d-%b-%Y"`/

Now compress the directory backup and make a ``.tar`` file::

tar -zcvf $path/of/backup/nextcloud_`date +"%d-%b-%Y"`/nextcloud_directory_backup_`date +"%d-%b-%Y"`.tar.gz $path/of/backup/nextcloud_`date +"%d-%b-%Y"`/nextcloud_directory_backup_`date +"%d-%b-%Y"`/

After the archiving is successfully complete we can delete the ``nextcloud_directory_backup_`date +"%d-%b-%Y"`/`` directory::

rm -rf $path/of/backup/nextcloud_`date +"%d-%b-%Y"`/nextcloud_directory_backup_`date +"%d-%b-%Y"`/

Backup database
```````````````
Now we will backup the PostgreSQL database::

PGPASSWORD="$password" pg_dump nextcloud -h localhost -U $username -f $path/of/backup/nextcloud_`date +"%d-%b-%Y"`/nextcloud_`date +"%d-%b-%Y"`.dump
PGPASSWORD="$password" pg_dump nextcloud -h localhost -U $username -f $path/of/backup/nextcloud_`date +"%d-%b-%Y"`/nextcloud_databese_backup_`date +"%d-%b-%Y"`.dump

Compress backup
```````````````
Finally, we compress the directory to make a single ``.tar`` file from it::
Compress full backup
````````````````````
Finally, we will bundle the directory backup archive with the database backup and make it a single ``.tar`` file::

tar -zcvf $path/of/backup/nextcloud_`date +"%d-%b-%Y"`.tar.gz $path/of/backup/nextcloud_`date +"%d-%b-%Y"`/

And we are done with backup!

Turn off maintenance mode
`````````````````````````
Run the following command to turn off maintenance mode::

sudo -u www-data php $path/to/webserver/document-root/nextcloud/occ maintenance:mode --off


Restore
-------
Expand All @@ -207,15 +226,21 @@ To restore a Nextcloud installation there are four main things you need to resto

Decompress backup (if you have any)
```````````````````````````````````
Assuming you have a made a compressed backup archive following `Compress backup`_ and want to restore that, we need to Decompress the backup archive.::
Assuming we have a made a compressed backup archive following `Compress backup`_ and want to restore that, we need to Decompress the backup archive.::

tar -xvzf $path/of/backup/nextcloud_$month-date-year.tar.gz

At this step, we should see one archive named ``nextcloud_directory_backup_$month-date-year.tar.gz`` and a database dump named ``nextcloud_databese_backup``.

Restore folders
```````````````
Next we will copy the decompressed directory to webserver root::
If we found the archive named ``nextcloud_directory_backup_$month-date-year.tar.gz`` containng Nextcloud config, data and theme dir. We need to decompress this directory::

tar -xvzf $path/of/backup/nextcloud_directory_backup_$month-date-year.tar.gz

Then, we copy the decompressed directory to webserver root::

sudo rsync -Aax nextcloud_$month-date-year/ $path/to/webserver/document-root/nextcloud/
sudo rsync -Aax nextcloud_directory_backup_$month-date-year/ $path/to/webserver/document-root/nextcloud/

Restore database
````````````````
Expand All @@ -226,12 +251,7 @@ To restore database we need to delete the old database and create a new one wher

Now we use the following command to restore the database::

PGPASSWORD="$password" pg_restore -c -d nextcloud -h localhost -U $username $path/of/backup/nextcloud_$month-date-year/nextcloud_$month-date-year.dump


We have one task left to do which is deleting the ``.dump`` file from the ``nextcloud`` directory in webserver. We put the ``.dump`` in the same directory as ``nextcloud`` backup directory for the convenience of archiving but keeping it in the webserver is a big NO NO. So let's delete the ``.dump`` file::

sudo rm path/to/webserver/document-root/nextcloud/nextcloud_$month-date-year.dump
PGPASSWORD="$password" pg_restore -c -d nextcloud -h localhost -U $username $path/of/backup/nextcloud_$month-date-year/nextcloud_databese_backup_$month-date-year.dump



Expand Down
1 change: 1 addition & 0 deletions docs/gitea.html
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ <h2>Add reStructuredText(rST) perser<a class="headerlink" href="#add-restructure
<span class="n">IS_INPUT_FILE</span> <span class="o">=</span> <span class="n">false</span>
</pre></div>
</div>
<p>Now save the file and restart the gitea service.</p>
</div>
<div class="section" id="source">
<h2>Source<a class="headerlink" href="#source" title="Permalink to this headline"></a></h2>
Expand Down
53 changes: 39 additions & 14 deletions docs/nextcloud.html
Original file line number Diff line number Diff line change
Expand Up @@ -208,28 +208,50 @@ <h3>Turn on maintenance mode<a class="headerlink" href="#turn-on-maintenance-mod
</pre></div>
</div>
</div>
<div class="section" id="make-a-backup-directory">
<h3>Make a backup directory<a class="headerlink" href="#make-a-backup-directory" title="Permalink to this headline"></a></h3>
<p>We will make a temporery backup directory where we will story the backup files and directorys until we make a single <code class="docutils literal"><span class="pre">.tar</span></code> archive from them.:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>mkdir $path/of/backup/nextcloud_`date +&quot;%d-%b-%Y&quot;`
</pre></div>
</div>
</div>
<div class="section" id="backup-folders">
<h3>Backup folders<a class="headerlink" href="#backup-folders" title="Permalink to this headline"></a></h3>
<p>Simply copy config, data and theme folders (or even our whole Nextcloud install and data folder) to a place outside of our Nextcloud environment. We can use this command:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>sudo rsync -Aax $path/to/webserver/document-root/nextcloud/ $path/of/backup/nextcloud_`date +&quot;%d-%b-%Y&quot;`/
<div class="highlight-default"><div class="highlight"><pre><span></span>sudo rsync -Aax $path/to/webserver/document-root/nextcloud/ $path/of/backup/nextcloud_`date +&quot;%d-%b-%Y&quot;`/nextcloud_directory_backup_`date +&quot;%d-%b-%Y&quot;`/
</pre></div>
</div>
<p>Now compress the directory backup and make a <code class="docutils literal"><span class="pre">.tar</span></code> file:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>tar -zcvf $path/of/backup/nextcloud_`date +&quot;%d-%b-%Y&quot;`/nextcloud_directory_backup_`date +&quot;%d-%b-%Y&quot;`.tar.gz $path/of/backup/nextcloud_`date +&quot;%d-%b-%Y&quot;`/nextcloud_directory_backup_`date +&quot;%d-%b-%Y&quot;`/
</pre></div>
</div>
<p>After the archiving is successfully complete we can delete the <code class="docutils literal"><span class="pre">nextcloud_directory_backup_`date</span> <span class="pre">+&quot;%d-%b-%Y&quot;`/</span></code> directory:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>rm -rf $path/of/backup/nextcloud_`date +&quot;%d-%b-%Y&quot;`/nextcloud_directory_backup_`date +&quot;%d-%b-%Y&quot;`/
</pre></div>
</div>
</div>
<div class="section" id="backup-database">
<h3>Backup database<a class="headerlink" href="#backup-database" title="Permalink to this headline"></a></h3>
<p>Now we will backup the PostgreSQL database:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>PGPASSWORD=&quot;$password&quot; pg_dump nextcloud -h localhost -U $username -f $path/of/backup/nextcloud_`date +&quot;%d-%b-%Y&quot;`/nextcloud_`date +&quot;%d-%b-%Y&quot;`.dump
<div class="highlight-default"><div class="highlight"><pre><span></span>PGPASSWORD=&quot;$password&quot; pg_dump nextcloud -h localhost -U $username -f $path/of/backup/nextcloud_`date +&quot;%d-%b-%Y&quot;`/nextcloud_databese_backup_`date +&quot;%d-%b-%Y&quot;`.dump
</pre></div>
</div>
</div>
<div class="section" id="compress-backup">
<h3>Compress backup<a class="headerlink" href="#compress-backup" title="Permalink to this headline"></a></h3>
<p>Finally, we compress the directory to make a single <code class="docutils literal"><span class="pre">.tar</span></code> file from it:</p>
<div class="section" id="compress-full-backup">
<h3>Compress full backup<a class="headerlink" href="#compress-full-backup" title="Permalink to this headline"></a></h3>
<p>Finally, we will bundle the directory backup archive with the database backup and make it a single <code class="docutils literal"><span class="pre">.tar</span></code> file:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>tar -zcvf $path/of/backup/nextcloud_`date +&quot;%d-%b-%Y&quot;`.tar.gz $path/of/backup/nextcloud_`date +&quot;%d-%b-%Y&quot;`/
</pre></div>
</div>
<p>And we are done with backup!</p>
</div>
<div class="section" id="turn-off-maintenance-mode">
<h3>Turn off maintenance mode<a class="headerlink" href="#turn-off-maintenance-mode" title="Permalink to this headline"></a></h3>
<p>Run the following command to turn off maintenance mode:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>sudo -u www-data php $path/to/webserver/document-root/nextcloud/occ maintenance:mode --off
</pre></div>
</div>
</div>
</div>
<div class="section" id="restore">
<h2>Restore<a class="headerlink" href="#restore" title="Permalink to this headline"></a></h2>
Expand All @@ -246,15 +268,20 @@ <h2>Restore<a class="headerlink" href="#restore" title="Permalink to this headli
</div>
<div class="section" id="decompress-backup-if-you-have-any">
<h3>Decompress backup (if you have any)<a class="headerlink" href="#decompress-backup-if-you-have-any" title="Permalink to this headline"></a></h3>
<p>Assuming you have a made a compressed backup archive following <a class="reference internal" href="#compress-backup">Compress backup</a> and want to restore that, we need to Decompress the backup archive.:</p>
<p>Assuming we have a made a compressed backup archive following <a href="#id3"><span class="problematic" id="id4">`Compress backup`_</span></a> and want to restore that, we need to Decompress the backup archive.:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>tar -xvzf $path/of/backup/nextcloud_$month-date-year.tar.gz
</pre></div>
</div>
<p>At this step, we should see one archive named <code class="docutils literal"><span class="pre">nextcloud_directory_backup_$month-date-year.tar.gz</span></code> and a database dump named <code class="docutils literal"><span class="pre">nextcloud_databese_backup</span></code>.</p>
</div>
<div class="section" id="restore-folders">
<h3>Restore folders<a class="headerlink" href="#restore-folders" title="Permalink to this headline"></a></h3>
<p>Next we will copy the decompressed directory to webserver root:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>sudo rsync -Aax nextcloud_$month-date-year/ $path/to/webserver/document-root/nextcloud/
<p>If we found the archive named <code class="docutils literal"><span class="pre">nextcloud_directory_backup_$month-date-year.tar.gz</span></code> containng Nextcloud config, data and theme dir. We need to decompress this directory:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>tar -xvzf $path/of/backup/nextcloud_directory_backup_$month-date-year.tar.gz
</pre></div>
</div>
<p>Then, we copy the decompressed directory to webserver root:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>sudo rsync -Aax nextcloud_directory_backup_$month-date-year/ $path/to/webserver/document-root/nextcloud/
</pre></div>
</div>
</div>
Expand All @@ -266,11 +293,7 @@ <h3>Restore database<a class="headerlink" href="#restore-database" title="Permal
</pre></div>
</div>
<p>Now we use the following command to restore the database:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>PGPASSWORD=&quot;$password&quot; pg_restore -c -d nextcloud -h localhost -U $username $path/of/backup/nextcloud_$month-date-year/nextcloud_$month-date-year.dump
</pre></div>
</div>
<p>We have one task left to do which is deleting the <code class="docutils literal"><span class="pre">.dump</span></code> file from the <code class="docutils literal"><span class="pre">nextcloud</span></code> directory in webserver. We put the <code class="docutils literal"><span class="pre">.dump</span></code> in the same directory as <code class="docutils literal"><span class="pre">nextcloud</span></code> backup directory for the convenience of archiving but keeping it in the webserver is a big NO NO. So let’s delete the <code class="docutils literal"><span class="pre">.dump</span></code> file:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>sudo rm path/to/webserver/document-root/nextcloud/nextcloud_$month-date-year.dump
<div class="highlight-default"><div class="highlight"><pre><span></span>PGPASSWORD=&quot;$password&quot; pg_restore -c -d nextcloud -h localhost -U $username $path/of/backup/nextcloud_$month-date-year/nextcloud_databese_backup_$month-date-year.dump
</pre></div>
</div>
</div>
Expand Down Expand Up @@ -335,9 +358,11 @@ <h3><a href="index.html">Table Of Contents</a></h3>
<li><a class="reference internal" href="#enabling-ssl">Enabling SSL</a></li>
<li><a class="reference internal" href="#backup">Backup</a><ul>
<li><a class="reference internal" href="#turn-on-maintenance-mode">Turn on maintenance mode</a></li>
<li><a class="reference internal" href="#make-a-backup-directory">Make a backup directory</a></li>
<li><a class="reference internal" href="#backup-folders">Backup folders</a></li>
<li><a class="reference internal" href="#backup-database">Backup database</a></li>
<li><a class="reference internal" href="#compress-backup">Compress backup</a></li>
<li><a class="reference internal" href="#compress-full-backup">Compress full backup</a></li>
<li><a class="reference internal" href="#turn-off-maintenance-mode">Turn off maintenance mode</a></li>
</ul>
</li>
<li><a class="reference internal" href="#restore">Restore</a><ul>
Expand Down
Loading

0 comments on commit 1ff1b34

Please sign in to comment.