T
T
Teutonick2010-09-17 08:32:49
PHP
Teutonick, 2010-09-17 08:32:49

How to implement backups of content versions when creating an article? (PHP, MySQL)?

For example, in WordPress there is such a feature
20100917-qcqt-19kb.jpg
. That is, for each article there are several versions saved at a certain interval with the possibility of rolling back to each of them. Please tell me how to correctly implement this using PHP and MySQl! Thanks

Answer the question

In order to leave comments, you need to log in

5 answer(s)
L
LIAL, 2010-09-17
@LIAL

targz + cron

L
LIAL, 2010-09-17
@LIAL

This is more of a feature of the system and not PHP + MySQL (although I think you can tie it from under them.)
I have a site backed up + database:
1. tar -cvzf /_mybackups/NAME_www.tgz /home/NAME/public_html /home/NAME/ includes - those directories that I need to archive
2. mysqldump -h localhost -u LOGIN PASSWORD -d DATABASE > /_mybackups/db_service.sql - I dump from the database
3. tar -cvzf /_mybackups/db_service.tgz /_mybackups/db_service .sql - base to the archive
4. rm /_mybackups/db_service.sql - delete the dump
Thus, the output is the archive with the database and with the site
about the crowns (Cron) google - there is nothing complicated. And these are my 4 crown tasks, which you yourself set as often as you need. if necessary, you can do versioning by dates. you don’t need to program anything - once you set it up and you always have an archive with what you need

A
Alexander, 2010-09-17
@0lympian

Most likely there the database structure includes this feature: when saving, the data is not replaced by an update in the database, but a new line is added.
The simplest structure with the minimum number of required fields looks like this:
- article_id (not unique)
- timestamp
- content
Accordingly, when saving, we add a new line with the same ID, but with a more recent timestamp. When sampling, we take the most recent one (requests with grouping, or an additional updated field with a flag for pefomance).

M
MastaEx, 2010-09-17
@MastaEx

And for some reason I'm sure that diffs are simply saved there.
So take wordpress and see exactly how they are saved.

S
shelestov, 2010-09-20
@shelestov

Store articles in Subversion

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question