social-doc/docs/admin/backing_up_and_restoring.rst
John Kristensen 49c0114104 Initial port of admin manual to Sphinx
A port of the existing admin manual over to reStructuredText and using
Sphinx to generate the documentation to see if it would be a suitable
replacement for the existing php generated method.
2016-03-06 01:50:52 +11:00

96 lines
3.0 KiB
ReStructuredText

Backing Up and Restoring
========================
Backing Up
----------
It is important to back up GNU social regularly. If you need to revert to an
old backup you will lose any newer notices. Any follows that happened since
then will result in mismatched information on your server and remote servers.
You should also back up immediately prior to any upgrade. This is especially
important if you are following the *nightly* branch where serious bugs might
slip through.
There are two parts to your GNU social installation and they most *both* be
backed up at the same time.
1. The files hosted by your webserver. This is a mixture of GNU social code and
user data. This a directory probably located somewhere like
``/var/www/social``.
2. The contents of the MariaDB/MySQL database.
Web Files
^^^^^^^^^
You don't need to do anything fancy. Just make sure you have a copy of the
folder. If you're using a commercial web hosting service there is probably a
button you can press to download an archive of all your files. Note that this
normally does *not* include your database.
If you have shell access on the server, assuming the GNU social folder is
located at ``/var/www/social``, you can make a compressed backup in your home
directory like this::
TIMESTAMP=$(date +%Y%m%d-%H%M)
cd /var/www
tar -Jcf "~/$TIMESTAMP-social-www.tar.xz" --exclude=.git social
If you are serving files straight out of the git repository this will back up
only the currently checked out copy, not the entire history. (Using a git
repository this way is not recommended as you may cause chaos in your database
if you accidentally check out the wrong thing.)
Database
^^^^^^^^
There are many different tools and techniques for backing up MySQL databases.
If you're using a commercial web hosting service there will probably be
somewhere in the web interface where you can download a copy of the GNU social
database.
If you have shell access the simplest way to create a backup is using the tool
*mysqldump*. ::
TIMESTAMP=$(date +%Y%m%d-%H%M)
mysqldump -u "database_username" -p "database_name" | xz -c - > "~/$TIMESTAMP-social.sql.xz"
You will be prompted for a password. Type in the password for the MySQL user.
Restoring from a Backup
-----------------------
1. Stop the queue daemons if they're running.
2. Restore the web files.
3. Restore the database.
4. Restart the queue daemons.
If you followed the examples above you might type the following::
cd /var/www/social
# Stop the daemons
bash ./scripts/stopdaemons.sh
# Delete and restore the web files
rm -r *
cd ..
tar -Jxf ~/20160130-1200-social-www.tar.xz
# Recreate the database (using MySQL root account)
mysqladmin -u root -p drop social
mysqladmin -u root -p create social
mysql -u root -p social
# Inside mysql client
GRANT ALL on social.* TO 'social'@'localhost' IDENTIFIED BY 'the_old_password';
exit
# Restore the database as the GNU social MySQL user
xzcat ~/20160130-1200-social.sql.xz | mysql -u social -p social
# Restart the queue daemons
cd social
bash ./scripts/startdaemons.sh