Announcement

#1 2017-01-03 02:04:21

rlfedor
Member
2016-12-30
5

How to fully backup a Piwigo Gallery

Hello/Hi/Greetings,

I'm running Piwigo on a VPS and would like to backup to a secondary VPS, but I can't find a sold tutorial or plugin that explains exactly which files to copy.  Can someone link me to a guide that explains this.  I read the few backup instructions on the Upgrade guide but doesn't feel complete.

Thanks

Piwigo version: 2.8.5
PHP version: 7.0
MySQL version: 14.14 Distr 5.7.16
Piwigo URL: http://www.freddysfotos.me

Offline

 

#2 2017-01-03 08:29:37

flop25
Piwigo Team
2006-07-06
7037

Re: How to fully backup a Piwigo Gallery

Hello
to fully backup any CMS, save files and database


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#3 2017-01-03 10:38:34

CharlieM
Member
Gloucester, UK
2015-04-27
71

Re: How to fully backup a Piwigo Gallery

Is this a one off backup or a regular one @rlfedor?

Offline

 

#4 2017-01-03 20:30:17

rlfedor
Member
2016-12-30
5

Re: How to fully backup a Piwigo Gallery

I would ideally like to schedule regular backups to an off-site VPS.  I created a Pwigo gallery for my dad and after seeing all the time and effort into getting up and running, I would like to be able to back it up for a quick restore if needed.

Last edited by rlfedor (2017-01-03 20:31:28)

Offline

 

#5 2017-01-03 23:54:06

Zentalquabula
Member
2014-05-10
217

Re: How to fully backup a Piwigo Gallery

Make a script called backup.sh like below (you need to modify it, test it, and perhaps improve it):

Code:

#!/bin/bash

DATE=`date "+%Y-%m-%d-%H%M"`
DIR="/path/to/backupfolder/$DATE"
mkdir $DIR
cd $DIR

/usr/bin/mysqldump -r backup.sql --databases your_piwigo_database_name
/bin/gzip backup.sql

tar -zcvf piwigo.tar.gz /path/to/www/piwigo_folder

scp backup.sql.gz yourusername@yourothervps:/home/yourusername/backup.sql.gz.$DIR
scp piwigo.tar.gz yourusername@yourothervps:/home/yourusername/piwigo.tar.gz.$DIR

rm -f backup.sql.gz piwigo.tar.gz

Then do

Code:

chmod u+x backup.sh

to make it executable.

Then readup about crontab for your system, and make it run the script once a day, preferably at night. On Ubuntu 16, you would create a file by typing

Code:

sudo pico /etc/cron.d/anyfilename

and add:

Code:

# Nightly MySQL backup
1 2 * * *  yourusername if [ -x /home/yourusername/backup.sh ]; then /home/yourusername/backup.sh > /dev/null; fi

To make it autonomous (no password), you would need to add the appropriate ssh keys on your other VPS. Google it.

rlfedor wrote:

I would ideally like to schedule regular backups to an off-site VPS.  I created a Pwigo gallery for my dad and after seeing all the time and effort into getting up and running, I would like to be able to back it up for a quick restore if needed.

Offline

 

#6 2017-01-06 00:51:33

rlfedor
Member
2016-12-30
5

Re: How to fully backup a Piwigo Gallery

Thanks :)  Will work on it.

Offline

 

#7 2017-01-06 08:08:32

eliz82
Member
Romania
2016-04-27
281

Re: How to fully backup a Piwigo Gallery

Zentalquabula wrote:

Make a script called backup.sh like below (you need to modify it, test it, and perhaps improve it):

nice script, i made in the past weeks at something similar but more simple.
i have copied the database files directly without making an sql dump.

usually the files are in the /var/ directory, but you can move them anywhere by setting "datadir    = /var/somefolder/" in "/etc/my.conf" .

i can confirm that backup with the files copied directly if working fine, but it was tested on a non-production server. i don't know what it may happened if some data is written in the database exactly when you are copying the files.

so probably using sqldump is better , maybe it has some protection algorithms that wait for the data to be completely written (SQL query) then pauses all queries while making a dump. i think i will adopt your solution is probably more safe.

Offline

 

#8 2017-01-06 10:02:44

eliz82
Member
Romania
2016-04-27
281

Re: How to fully backup a Piwigo Gallery

by the way i have tried to execute
"mysqldump -r backup.sql --databases your_piwigo_database_name"
in the shell console and it give me an error

mysqldump: Got error: 1045: Access denied for user 'root'@'localhost' (using password: NO) when trying to connect

this one that specify a mysql user and password is working:
mysqldump -u root -pmypassword -r backup.sql --databases your_piwigo_database_name
or
mysqldump --user=root --password=mypassword -r backup.sql --databases your_piwigo_database_name

Last edited by eliz82 (2017-01-06 13:40:10)

Offline

 

#9 2017-01-06 15:30:17

Zentalquabula
Member
2014-05-10
217

Re: How to fully backup a Piwigo Gallery

You set the password in ~/.my.cnf and then protect it with chmod 600 ~/.my.cnf, otherwise there will be a warning message about insecure handling of passwords, which may interfere with the script.

Code:

[client]
user=root
password=yourpassword
socket=/var/run/mysqld/mysqld.sock

eliz82 wrote:

by the way i have tried to execute
"mysqldump -r backup.sql --databases your_piwigo_database_name"
in the shell console and it give me an error

mysqldump: Got error: 1045: Access denied for user 'root'@'localhost' (using password: NO) when trying to connect

this one that specify a mysql user and password is working:
mysqldump -u root -pmypassword -r backup.sql --databases your_piwigo_database_name
or
mysqldump --user=root --password=mypassword -r backup.sql --databases your_piwigo_database_name

Offline

 

#10 2022-11-17 23:27:22

bradawk1
Member
2022-02-12
15

Re: How to fully backup a Piwigo Gallery

Thanks!  This helped!  :)

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact