Historique de Nico.BackupPmWiki
Cacher les modifications mineures - Affichage de la sortie
01 mars 2007 à 23h16
par
- Ligne 13 modifiée:
but saves all directories mentionned at [[http://www.pmwiki.org/wiki/PmWiki/BackupAndRestore|BackupAndRestore]]
en:
but saves all directories mentioned at [[http://www.pmwiki.org/wiki/PmWiki/BackupAndRestore|BackupAndRestore]]
Lignes 16-17 modifiées:
It also fixes several bugs mentionned at [[http://www.pmwiki.org/wiki/Cookbook/BackupPages|BackupPages]].
en:
It also fixes several bugs mentioned at [[http://www.pmwiki.org/wiki/Cookbook/BackupPages|BackupPages]].
Lignes 35-36 modifiées:
This backup page can be read protected though [@?action=backup@] is still possible on a read protected page. A cryptic name for the page and directory can help protection.
en:
This backup page can be read protected though [@?action=backup@] is still possible on a read protected page. A cryptic name for the page and directory can help protection, or back_pmwiki.php can be edited to use an action name different from [@backup@].
Anyone can download the backup archive file if they know or can guess its URL.
Anyone can download the backup archive file if they know or can guess its URL.
Ligne 43 ajoutée:
*[[http://permalink.gmane.org/gmane.comp.web.wiki.pmwiki.user/39324|Modified BackupPages script]], adds ability to e-mail backup archive
01 mars 2007 à 11h44
par
- Ligne 75 modifiée:
[@set_time_limit(#of seconds); #for dev only!@\\
en:
[@set_time_limit(#of seconds); #for dev only!@]\\
01 mars 2007 à 11h43
par
- Lignes 74-77 ajoutées:
Try\\
[@set_time_limit(#of seconds); #for dev only!@\\
in config php - I set mine very high for dev, pmwiki can crunch for 24 hours if I want. Seth
[@set_time_limit(#of seconds); #for dev only!@\\
in config php - I set mine very high for dev, pmwiki can crunch for 24 hours if I want. Seth
21 octobre 2006 à 16h20
par
- Lignes 70-71 modifiées:
Try the new version (V1.1). It may fix your problem...
en:
Try the new version (V1.1, updated with new version of zip package, fixing some bugs). It may solve your problem...
18 octobre 2006 à 01h05
par
- Lignes 70-71 modifiées:
Try the new version. It may fix your problem...
en:
Try the new version (V1.1). It may fix your problem...
18 octobre 2006 à 00h59
par
- Lignes 68-69 modifiées:
[[~Francis]] 04 septembre 2006 à 10h42
en:
[[http://www.pmwiki.org/wiki/Profiles/Francis|Francis]] 04 septembre 2006 à 10h42
Try the new version. It may fix your problem...
[[http://www.pmwiki.org/wiki/Profiles/Nicolas|Nicolas]] October 17, 2006
!!!History
* V1.1 October 17, 2006 : integrated V2.1 of zip package from Devin Doucette. This may fix some bugs...
* V1.0 August 15, 2006 : first version.
Try the new version. It may fix your problem...
[[http://www.pmwiki.org/wiki/Profiles/Nicolas|Nicolas]] October 17, 2006
!!!History
* V1.1 October 17, 2006 : integrated V2.1 of zip package from Devin Doucette. This may fix some bugs...
* V1.0 August 15, 2006 : first version.
04 septembre 2006 à 10h43
par
- Lignes 66-67 modifiées:
* Actaully, with my problem this wasn't the case - I downloaded the file by ftp and it was a corrupted archive that couldn't be opened
en:
* Actually, with my problem this wasn't the case - I downloaded the file by ftp and it was a corrupted archive that couldn't be opened
04 septembre 2006 à 10h42
par
- Lignes 66-69 ajoutées:
* Actaully, with my problem this wasn't the case - I downloaded the file by ftp and it was a corrupted archive that couldn't be opened
[[~Francis]] 04 septembre 2006 à 10h42
[[~Francis]] 04 septembre 2006 à 10h42
03 septembre 2006 à 15h45
par
- Lignes 53-54 modifiées:
I have had trouble backing up our 'pub' directory which contains enough images to make the archive bigger than 50Mb. When it gets this big, the script crashes. So I have excluded the pub directory from the backup and it works fine for 20mb archives. Is this a bug, or something to do with my servers' setup? [[http://www.pmwiki.org/wiki/Profiles/Francis|Francis]] 02 septembre 2006 à 05h19
en:
I have had trouble backing up our 'pub' directory which contains enough images to make the archive bigger than 50Mb. When it gets this big, the script crashes. So I have excluded the pub directory from the backup and it works fine for 20mb archives. Is this a bug, or something to do with my servers' setup?
[[http://www.pmwiki.org/wiki/Profiles/Francis|Francis]] 02 septembre 2006 à 05h19
[[http://www.pmwiki.org/wiki/Profiles/Francis|Francis]] 02 septembre 2006 à 05h19
Ligne 63 ajoutée:
03 septembre 2006 à 15h45
par
- Lignes 53-55 modifiées:
I have had trouble backing up our 'pub' directory which contains enough images to make the archive bigger than 50Mb. When it gets this big, the script crashes. So I have excluded the pub directory from the backup and it works fine for 20mb archives. Is this a bug, or something to do with my servers' setup? [[~Francis]] 02 septembre 2006 à 05h19
en:
I have had trouble backing up our 'pub' directory which contains enough images to make the archive bigger than 50Mb. When it gets this big, the script crashes. So I have excluded the pub directory from the backup and it works fine for 20mb archives. Is this a bug, or something to do with my servers' setup? [[http://www.pmwiki.org/wiki/Profiles/Francis|Francis]] 02 septembre 2006 à 05h19
I successfully generated zip files larger than 130 Mo, but sometimes, for this kind of big archives, it seems that
the HTML output between http server and client is "to slow" and may let think the script crashes. In fact, the zip is
correctly generated (and can be obtained via FTP).
If anyone as an idea to prevent this "HTML output hanging",
it would be helpful...
[[http://www.pmwiki.org/wiki/Profiles/Nicolas|Nicolas]] September 3, 2006
I successfully generated zip files larger than 130 Mo, but sometimes, for this kind of big archives, it seems that
the HTML output between http server and client is "to slow" and may let think the script crashes. In fact, the zip is
correctly generated (and can be obtained via FTP).
If anyone as an idea to prevent this "HTML output hanging",
it would be helpful...
[[http://www.pmwiki.org/wiki/Profiles/Nicolas|Nicolas]] September 3, 2006
02 septembre 2006 à 05h19
par
- Possible Bug?Lignes 53-55 modifiées:
en:
I have had trouble backing up our 'pub' directory which contains enough images to make the archive bigger than 50Mb. When it gets this big, the script crashes. So I have excluded the pub directory from the backup and it works fine for 20mb archives. Is this a bug, or something to do with my servers' setup? [[~Francis]] 02 septembre 2006 à 05h19
15 août 2006 à 15h06
par
- Ligne 13 modifiée:
but saves all directories mentionned at [[http://www.pmwiki.org/wiki/PmWiki/BackupAndRestore|BackupAndRestore]],
en:
but saves all directories mentionned at [[http://www.pmwiki.org/wiki/PmWiki/BackupAndRestore|BackupAndRestore]]
15 août 2006 à 15h05
par
- Lignes 9-10 modifiées:
The Attach:backup_pmwiki.txt script (rename it to php) adds an "?action=backup" which can be used to backup the wiki.d directory and subdirectory too. You can configure the directory where to place backups, set up the backup format and if you want, at the end of creation of backup file, show a link to download it.
en:
The Attach:backup_pmwiki.txt script (rename it to php) adds an "?action=backup" which can be used to backup all the useful directories (and subdirectories). You can configure the directory where to place backups, set up the backup format and if you want, at the end of creation of backup file, show a link to download it.
15 août 2006 à 15h04
par
- Ligne 8 ajoutée:
15 août 2006 à 14h54
par
- Lignes 8-13 modifiées:
Attach:README.txt
Attach:backup_pmwiki.php.txt
The Attach:backup_pmwiki.php script adds an "?action=backup" which can be used to backup the wiki.d directory and subdirectory too. You can configure the directory where to place backups, set up the backup format and if you want, at the end of creation of backup file, show a link to download it.
Attach:backup_pmwiki.php.txt
The Attach:backup_pmwiki.php script adds an "?action=backup" which can be used to backup the wiki.d directory and subdirectory too. You can configure the directory where to place backups, set up the backup format and if you want, at the end of creation of backup file, show a link to download it.
en:
The Attach:backup_pmwiki.txt script (rename it to php) adds an "?action=backup" which can be used to backup the wiki.d directory and subdirectory too. You can configure the directory where to place backups, set up the backup format and if you want, at the end of creation of backup file, show a link to download it.
15 août 2006 à 14h39
par
- Lignes 8-9 ajoutées:
Attach:README.txt
15 août 2006 à 14h37
par
- Lignes 8-9 modifiées:
en:
Attach:backup_pmwiki.php.txt
15 août 2006 à 14h11
par
- Lignes 23-25 modifiées:
[@/local/Admin.BackupWiki.php@]
en:
/local/Admin.BackupWiki.php
Ligne 27 modifiée:
//$BackupDir = '/mybackupdirectory/'; // defaults to '/backup/'
en:
//$BackupDir = '/mybackupdirectory/'; // defaults to '/backup/'
15 août 2006 à 14h11
par
- Lignes 27-34 modifiées:
[=
<?php if (!defined('PmWiki')) exit();
//$BackupDir = '/mybackupdirectory/'; // defaults to '/backup/'
// other parameters : see backup_pmwiki.php
include_once('cookbook/backup_pmwiki.php');
?> =]
<?php if (!defined('PmWiki')) exit();
//$BackupDir = '/mybackupdirectory/'; // defaults to '/backup/'
// other parameters : see backup_pmwiki.php
include_once('cookbook/backup_pmwiki.php');
?> =]
en:
<?php if (!defined('PmWiki')) exit();
//$BackupDir = '/mybackupdirectory/'; // defaults to '/backup/'
// other parameters : see backup_pmwiki.php
include_once('cookbook/backup_pmwiki.php');
?>
//$BackupDir = '/mybackupdirectory/'; // defaults to '/backup/'
// other parameters : see backup_pmwiki.php
include_once('cookbook/backup_pmwiki.php');
?>
15 août 2006 à 14h09
par
- Ligne 44 ajoutée:
*[[http://www.pmwiki.org/wiki/PmWiki/BackupAndRestore|BackupAndRestore]]
Lignes 46-48 modifiées:
*[[http://www.pmwiki.org/wiki/PmWiki/BackupAndRestore|BackupAndRestore]]
en:
15 août 2006 à 14h08
par
- Ligne 44 modifiée:
*[[RestorePmWiki]]
en:
*[[http://www.pmwiki.org/wiki/Cookbook/RestorePmWiki|RestorePmWiki]]
15 août 2006 à 14h07
par
- Lignes 60-61 modifiées:
[[http://www.pmwiki.org/wiki/Profiles/SteveAgl|SteveAgl]] - Original script author
en:
[[http://www.pmwiki.org/wiki/Profiles/SteveAgl|SteveAgl]] - original script author
15 août 2006 à 14h07
par
- Lignes 62-63 modifiées:
[[http://www.pmwiki.org/wiki/Profiles/Nicolas|Nicolas]] - backup all useful directories
en:
[[http://www.pmwiki.org/wiki/Profiles/Nicolas|Nicolas]] - fixed bugs, and added backup of all useful directories
15 août 2006 à 14h03
par
- Lignes 65-68 ajoutées:
<img src="http://perso0.free.fr/cgi-bin/wwwcount.cgi?df=nicolas.raibaut.BackupPmWiki.dat&dd=E&ft=0"> [-visits-]
15 août 2006 à 14h01
par
- Lignes 57-59 modifiées:
!!!Contributor
en:
!!!Contributors
15 août 2006 à 14h00
par
- Lignes 54-56 modifiées:
[[~davidof]] August 15, 2006
en:
[[http://www.pmwiki.org/wiki/Profiles/Nicolas|Nicolas]] August 15, 2006
Lignes 60-63 modifiées:
[[~SteveAgl]] - Original script author
[[~Nicolas]] - backup all useful directories
[[~Nicolas]] - backup all useful directories
en:
[[http://www.pmwiki.org/wiki/Profiles/SteveAgl|SteveAgl]] - Original script author
[[http://www.pmwiki.org/wiki/Profiles/Nicolas|Nicolas]] - backup all useful directories
[[http://www.pmwiki.org/wiki/Profiles/Nicolas|Nicolas]] - backup all useful directories
15 août 2006 à 13h59
par
- Lignes 52-53 modifiées:
(%red%edit password = backup)
en:
%red%(edit password = '''backup''')
15 août 2006 à 13h59
par
- Lignes 51-52 modifiées:
Feel free to edit this page if you have any remarks...
en:
Feel free to edit this page if you have any remarks...
(%red%edit password = backup)
(%red%edit password = backup)
15 août 2006 à 13h56
par
- Ligne 37 ajoutée:
Lignes 41-42 ajoutées:
Ligne 50 ajoutée:
Ligne 58 ajoutée:
15 août 2006 à 13h56
par
- Lignes 20-21 modifiées:
The variable redefining the backup directory can be set '''before''' the script inclusion, as well as other parameter (see script).
en:
The variable redefining the backup directory can be set '''before''' the script inclusion, as well as other parameters (see script).
15 août 2006 à 13h55
par
- Lignes 9-10 modifiées:
The Attach:backup_pmwiki.php script adds an "?action=backup" which can be used to backup the wiki.d directory and subdirectory too. You can configure the directory where to place backups, set up the backup format and if, at the end of creation of backup file, show a link to download it.
en:
The Attach:backup_pmwiki.php script adds an "?action=backup" which can be used to backup the wiki.d directory and subdirectory too. You can configure the directory where to place backups, set up the backup format and if you want, at the end of creation of backup file, show a link to download it.
15 août 2006 à 13h54
par
- Ligne 3 ajoutée:
Ligne 8 ajoutée:
Ligne 10 supprimée:
Lignes 20-21 modifiées:
The variable redefining the backup directory should be set '''before''' the script inclusion.
en:
The variable redefining the backup directory can be set '''before''' the script inclusion, as well as other parameter (see script).
Lignes 30-32 modifiées:
$RecentChangesFmt = "";
$BackupDir = '/mybackupdirectory/';
include_once('cookbook/backup_pages.php');
$BackupDir = '/mybackupdirectory/';
include_once('cookbook/backup_pages.php');
en:
//$BackupDir = '/mybackupdirectory/'; // defaults to '/backup/'
// other parameters : see backup_pmwiki.php
include_once('cookbook/backup_pmwiki.php');
// other parameters : see backup_pmwiki.php
include_once('cookbook/backup_pmwiki.php');
Lignes 36-37 modifiées:
The script save only files which are in the ''/wiki.d/'' directory. You should save the content of the ''/files/'' directory apart.
en:
Ligne 40 ajoutée:
*[[http://www.pmwiki.org/wiki/Cookbook/BackupPages|BackupPages]] (original script)
Lignes 42-44 modifiées:
en:
*[[http://www.pmwiki.org/wiki/PmWiki/BackupAndRestore|BackupAndRestore]]
Lignes 47-135 modifiées:
I'm not greatly in favor of adding admin functions directly to pmwiki, instead I created the script below to backup and restore the wiki.d directory. This uses the PEAR File::Archive package.
[@<HTML>
<HEAD>
<TITLE>Admin Functions</TITLE>
<BODY>
<H1>pmwiki Administration Functions</H1>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
Backup Wiki <input type='radio' name='admin' value="backup"><br>
Restore Wiki <input type='radio' name='admin' value='restore'><br>
<input type=submit value="Submit">
<input type="hidden" name="_submit_check" value="1"/>
</form>
<?php
ini_set("include_path", $_SERVER['DOCUMENT_ROOT'] . "/pear_includes/");
require_once "File/Archive.php";
if (array_key_exists('_submit_check', $_POST)) {
if ($_POST['admin'] == 'backup') {
echo "<b>archiving wiki.d</b>";
File_Archive::extract(
File_Archive::read("wiki.d/"),
File_Archive::toArchive("archive.tgz",File_Archive::toFiles())
);
} else {
echo "<b>restoring wiki.d</b>";
File_Archive::extract(
File_Archive::read("archive.tgz/"),
File_Archive::toFiles("wiki.d/")
);
}
}
?>
</BODY>@]
[[~davidof]] September 3, 2005 at 4:44pm
This doesn't work properly with wikifarms. Making a backup will save the zip file in the chosen directory. Making a backup from more than one farm at once will overwrite the precedent backup
[[~kt007]] March 13, 2005, at 10:34 AM~
I'll try to solve the problem in a next version with will allow to backup wiki.d or files directory or both, adding a password protection too. For Farm i have to set a simply local one to test it, but casue the libray used to zip files allow appending too it's just an option to add to the command line or in the internal option configuration. Thanks for the note.
[[~SteveAgl]] March 13, 2005, at 11:10 AM
This seems to always generate a zip file regardless of the extension specified. Looks like the code should switch on the format to determine the archive class to use instead of always using @@zip_file@@. Also, the link generated for $@@`ShowLink@@ was incorrect; I fixed it with the following:
[=
If ($ShowLink) {
$BackupUrl = preg_replace('#/[^/]*$#',"$BackupDir",$ScriptUrl,1); # use instead of $ScriptUrl.$BackupDir
echo "<br /><br />You can download the backup file now:
<a href='".$BackupUrl.$BackupFile.$BackupFormat."'>".$BackupUrl.$BackupFile.$BackupFormat."</a>";
} =]
[[~KevinWatts]] April 15, 2005, at 11:52 PM
It would be usefull if one could specify just a directory, i.e. the root directory of the wiki, and the scripts stuffs all subdirectories excluding the archive directory itself to make a complete snapshot of a wiki including the scripts, cookbook etc.
[[~Schlaefer]] April 17, 2005, at 05:51 AM
If your wiki's name has a space in it, your zip-file will have this space in its name, too. This max be a problem, because some FTP-clients (e.g. `SmartFTP) won't do anything with such files (neither deleting nor renaming nor downloading). The solution is simple:
[=
If ($DateFormat = 1 ) {
SDV($BackupFile, str_replace(" ","",$WikiTitle)."_".date ("m-d-Y"));
} else {
SDV($BackupFile, str_replace(" ","",$WikiTitle)."_".date ("d-m-Y"));
} =]
[[~JustusvV]] June 14, 2005, at 08:54 AM
The Farm issue could be fixed changing the next lines
# Set the local path to backup directory
//SDV($BackupDirPath,$FarmD.$BackupDir);
SDV($BackupDirPath,$_SERVER[DOCUMENT_ROOT].$BackupDir); //for Farm
In my opinion this Cookbook receip should require the admin password
The spaces are not the only issue in archive name [='`=] could cause issues
[[~Isidor]]
To protect this cookbook and only alow admin to backup the wiki, you can add these lines :
[=
if (strpos($DefaultPasswords['admin'],$GLOBALS[authid])!==FALSE)
{
//Current Cookbook code here.
}
=]
[[~Chumalgare]]
[@<HTML>
<HEAD>
<TITLE>Admin Functions</TITLE>
<BODY>
<H1>pmwiki Administration Functions</H1>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
Backup Wiki <input type='radio' name='admin' value="backup"><br>
Restore Wiki <input type='radio' name='admin' value='restore'><br>
<input type=submit value="Submit">
<input type="hidden" name="_submit_check" value="1"/>
</form>
<?php
ini_set("include_path", $_SERVER['DOCUMENT_ROOT'] . "/pear_includes/");
require_once "File/Archive.php";
if (array_key_exists('_submit_check', $_POST)) {
if ($_POST['admin'] == 'backup') {
echo "<b>archiving wiki.d</b>";
File_Archive::extract(
File_Archive::read("wiki.d/"),
File_Archive::toArchive("archive.tgz",File_Archive::toFiles())
);
} else {
echo "<b>restoring wiki.d</b>";
File_Archive::extract(
File_Archive::read("archive.tgz/"),
File_Archive::toFiles("wiki.d/")
);
}
}
?>
</BODY>@]
[[~davidof]] September 3, 2005 at 4:44pm
This doesn't work properly with wikifarms. Making a backup will save the zip file in the chosen directory. Making a backup from more than one farm at once will overwrite the precedent backup
[[~kt007]] March 13, 2005, at 10:34 AM~
I'll try to solve the problem in a next version with will allow to backup wiki.d or files directory or both, adding a password protection too. For Farm i have to set a simply local one to test it, but casue the libray used to zip files allow appending too it's just an option to add to the command line or in the internal option configuration. Thanks for the note.
[[~SteveAgl]] March 13, 2005, at 11:10 AM
This seems to always generate a zip file regardless of the extension specified. Looks like the code should switch on the format to determine the archive class to use instead of always using @@zip_file@@. Also, the link generated for $@@`ShowLink@@ was incorrect; I fixed it with the following:
[=
If ($ShowLink) {
$BackupUrl = preg_replace('#/[^/]*$#',"$BackupDir",$ScriptUrl,1); # use instead of $ScriptUrl.$BackupDir
echo "<br /><br />You can download the backup file now:
<a href='".$BackupUrl.$BackupFile.$BackupFormat."'>".$BackupUrl.$BackupFile.$BackupFormat."</a>";
} =]
[[~KevinWatts]] April 15, 2005, at 11:52 PM
It would be usefull if one could specify just a directory, i.e. the root directory of the wiki, and the scripts stuffs all subdirectories excluding the archive directory itself to make a complete snapshot of a wiki including the scripts, cookbook etc.
[[~Schlaefer]] April 17, 2005, at 05:51 AM
If your wiki's name has a space in it, your zip-file will have this space in its name, too. This max be a problem, because some FTP-clients (e.g. `SmartFTP) won't do anything with such files (neither deleting nor renaming nor downloading). The solution is simple:
[=
If ($DateFormat = 1 ) {
SDV($BackupFile, str_replace(" ","",$WikiTitle)."_".date ("m-d-Y"));
} else {
SDV($BackupFile, str_replace(" ","",$WikiTitle)."_".date ("d-m-Y"));
} =]
[[~JustusvV]] June 14, 2005, at 08:54 AM
The Farm issue could be fixed changing the next lines
# Set the local path to backup directory
//SDV($BackupDirPath,$FarmD.$BackupDir);
SDV($BackupDirPath,$_SERVER[DOCUMENT_ROOT].$BackupDir); //for Farm
In my opinion this Cookbook receip should require the admin password
The spaces are not the only issue in archive name [='`=] could cause issues
[[~Isidor]]
To protect this cookbook and only alow admin to backup the wiki, you can add these lines :
[=
if (strpos($DefaultPasswords['admin'],$GLOBALS[authid])!==FALSE)
{
//Current Cookbook code here.
}
=]
[[~Chumalgare]]
en:
Feel free to edit this page if you have any remarks...
[[~davidof]] August 15, 2006
[[~davidof]] August 15, 2006
Ligne 58 modifiée:
Category: [[!Administration]]
en:
Category: [[!Administration]]
15 août 2006 à 13h48
par
- Lignes 7-10 modifiées:
The Attach:backup_pages.php script adds an "?action=backup" which can be used to backup the wiki.d directory and subdirectory too. You can configure the directory where to place backups, set up the backup format and if, at the end of creation of backup file, show a link to download it.
%red% The wiki.d directory only contains the text of the contents, which in many cases is not enough. See [[PmWiki/Backup]] for a more complete list of files recommended for manual backups, and, eventually, an automated way to do it. -- Susan
%red% The wiki.d directory only contains the text of the contents, which in many cases is not enough. See [[PmWiki/Backup]] for a more complete list of files recommended for manual backups, and, eventually, an automated way to do it. -- Susan
en:
The Attach:backup_pmwiki.php script adds an "?action=backup" which can be used to backup the wiki.d directory and subdirectory too. You can configure the directory where to place backups, set up the backup format and if, at the end of creation of backup file, show a link to download it.
This script is inspired from
[[http://www.pmwiki.org/wiki/Cookbook/BackupPages|BackupPages]],
but saves all directories mentionned at [[http://www.pmwiki.org/wiki/PmWiki/BackupAndRestore|BackupAndRestore]],
(and not only wiki.d).
It also fixes several bugs mentionned at [[http://www.pmwiki.org/wiki/Cookbook/BackupPages|BackupPages]].
This script is inspired from
[[http://www.pmwiki.org/wiki/Cookbook/BackupPages|BackupPages]],
but saves all directories mentionned at [[http://www.pmwiki.org/wiki/PmWiki/BackupAndRestore|BackupAndRestore]],
(and not only wiki.d).
It also fixes several bugs mentionned at [[http://www.pmwiki.org/wiki/Cookbook/BackupPages|BackupPages]].
15 août 2006 à 13h39
par
- Lignes 1-133 ajoutées:
!!!Question
(:Description Is there an easy way to automatically backup '''all''' useful directories to a .zip file?:){$Description}
!!!Answer
The Attach:backup_pages.php script adds an "?action=backup" which can be used to backup the wiki.d directory and subdirectory too. You can configure the directory where to place backups, set up the backup format and if, at the end of creation of backup file, show a link to download it.
%red% The wiki.d directory only contains the text of the contents, which in many cases is not enough. See [[PmWiki/Backup]] for a more complete list of files recommended for manual backups, and, eventually, an automated way to do it. -- Susan
Backup directory might be created by hand and given 777 rights.
The variable redefining the backup directory should be set '''before''' the script inclusion.
It is better that this script is set only for a dedicated page, and so, the include set in a file associated to this page like
[@/local/Admin.BackupWiki.php@]
This file may content something like :
[=
<?php if (!defined('PmWiki')) exit();
$RecentChangesFmt = "";
$BackupDir = '/mybackupdirectory/';
include_once('cookbook/backup_pages.php');
?> =]
!!!Restrictions
The script save only files which are in the ''/wiki.d/'' directory. You should save the content of the ''/files/'' directory apart.
This backup page can be read protected though [@?action=backup@] is still possible on a read protected page. A cryptic name for the page and directory can help protection.
!!!See also
*[[RestorePmWiki]]
!!!Discussion
I'm not greatly in favor of adding admin functions directly to pmwiki, instead I created the script below to backup and restore the wiki.d directory. This uses the PEAR File::Archive package.
[@<HTML>
<HEAD>
<TITLE>Admin Functions</TITLE>
<BODY>
<H1>pmwiki Administration Functions</H1>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
Backup Wiki <input type='radio' name='admin' value="backup"><br>
Restore Wiki <input type='radio' name='admin' value='restore'><br>
<input type=submit value="Submit">
<input type="hidden" name="_submit_check" value="1"/>
</form>
<?php
ini_set("include_path", $_SERVER['DOCUMENT_ROOT'] . "/pear_includes/");
require_once "File/Archive.php";
if (array_key_exists('_submit_check', $_POST)) {
if ($_POST['admin'] == 'backup') {
echo "<b>archiving wiki.d</b>";
File_Archive::extract(
File_Archive::read("wiki.d/"),
File_Archive::toArchive("archive.tgz",File_Archive::toFiles())
);
} else {
echo "<b>restoring wiki.d</b>";
File_Archive::extract(
File_Archive::read("archive.tgz/"),
File_Archive::toFiles("wiki.d/")
);
}
}
?>
</BODY>@]
[[~davidof]] September 3, 2005 at 4:44pm
This doesn't work properly with wikifarms. Making a backup will save the zip file in the chosen directory. Making a backup from more than one farm at once will overwrite the precedent backup
[[~kt007]] March 13, 2005, at 10:34 AM~
I'll try to solve the problem in a next version with will allow to backup wiki.d or files directory or both, adding a password protection too. For Farm i have to set a simply local one to test it, but casue the libray used to zip files allow appending too it's just an option to add to the command line or in the internal option configuration. Thanks for the note.
[[~SteveAgl]] March 13, 2005, at 11:10 AM
This seems to always generate a zip file regardless of the extension specified. Looks like the code should switch on the format to determine the archive class to use instead of always using @@zip_file@@. Also, the link generated for $@@`ShowLink@@ was incorrect; I fixed it with the following:
[=
If ($ShowLink) {
$BackupUrl = preg_replace('#/[^/]*$#',"$BackupDir",$ScriptUrl,1); # use instead of $ScriptUrl.$BackupDir
echo "<br /><br />You can download the backup file now:
<a href='".$BackupUrl.$BackupFile.$BackupFormat."'>".$BackupUrl.$BackupFile.$BackupFormat."</a>";
} =]
[[~KevinWatts]] April 15, 2005, at 11:52 PM
It would be usefull if one could specify just a directory, i.e. the root directory of the wiki, and the scripts stuffs all subdirectories excluding the archive directory itself to make a complete snapshot of a wiki including the scripts, cookbook etc.
[[~Schlaefer]] April 17, 2005, at 05:51 AM
If your wiki's name has a space in it, your zip-file will have this space in its name, too. This max be a problem, because some FTP-clients (e.g. `SmartFTP) won't do anything with such files (neither deleting nor renaming nor downloading). The solution is simple:
[=
If ($DateFormat = 1 ) {
SDV($BackupFile, str_replace(" ","",$WikiTitle)."_".date ("m-d-Y"));
} else {
SDV($BackupFile, str_replace(" ","",$WikiTitle)."_".date ("d-m-Y"));
} =]
[[~JustusvV]] June 14, 2005, at 08:54 AM
The Farm issue could be fixed changing the next lines
# Set the local path to backup directory
//SDV($BackupDirPath,$FarmD.$BackupDir);
SDV($BackupDirPath,$_SERVER[DOCUMENT_ROOT].$BackupDir); //for Farm
In my opinion this Cookbook receip should require the admin password
The spaces are not the only issue in archive name [='`=] could cause issues
[[~Isidor]]
To protect this cookbook and only alow admin to backup the wiki, you can add these lines :
[=
if (strpos($DefaultPasswords['admin'],$GLOBALS[authid])!==FALSE)
{
//Current Cookbook code here.
}
=]
[[~Chumalgare]]
!!!Contributor
[[~SteveAgl]] - Original script author
[[~Nicolas]] - backup all useful directories
Category: [[!Administration]]
(:Description Is there an easy way to automatically backup '''all''' useful directories to a .zip file?:){$Description}
!!!Answer
The Attach:backup_pages.php script adds an "?action=backup" which can be used to backup the wiki.d directory and subdirectory too. You can configure the directory where to place backups, set up the backup format and if, at the end of creation of backup file, show a link to download it.
%red% The wiki.d directory only contains the text of the contents, which in many cases is not enough. See [[PmWiki/Backup]] for a more complete list of files recommended for manual backups, and, eventually, an automated way to do it. -- Susan
Backup directory might be created by hand and given 777 rights.
The variable redefining the backup directory should be set '''before''' the script inclusion.
It is better that this script is set only for a dedicated page, and so, the include set in a file associated to this page like
[@/local/Admin.BackupWiki.php@]
This file may content something like :
[=
<?php if (!defined('PmWiki')) exit();
$RecentChangesFmt = "";
$BackupDir = '/mybackupdirectory/';
include_once('cookbook/backup_pages.php');
?> =]
!!!Restrictions
The script save only files which are in the ''/wiki.d/'' directory. You should save the content of the ''/files/'' directory apart.
This backup page can be read protected though [@?action=backup@] is still possible on a read protected page. A cryptic name for the page and directory can help protection.
!!!See also
*[[RestorePmWiki]]
!!!Discussion
I'm not greatly in favor of adding admin functions directly to pmwiki, instead I created the script below to backup and restore the wiki.d directory. This uses the PEAR File::Archive package.
[@<HTML>
<HEAD>
<TITLE>Admin Functions</TITLE>
<BODY>
<H1>pmwiki Administration Functions</H1>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
Backup Wiki <input type='radio' name='admin' value="backup"><br>
Restore Wiki <input type='radio' name='admin' value='restore'><br>
<input type=submit value="Submit">
<input type="hidden" name="_submit_check" value="1"/>
</form>
<?php
ini_set("include_path", $_SERVER['DOCUMENT_ROOT'] . "/pear_includes/");
require_once "File/Archive.php";
if (array_key_exists('_submit_check', $_POST)) {
if ($_POST['admin'] == 'backup') {
echo "<b>archiving wiki.d</b>";
File_Archive::extract(
File_Archive::read("wiki.d/"),
File_Archive::toArchive("archive.tgz",File_Archive::toFiles())
);
} else {
echo "<b>restoring wiki.d</b>";
File_Archive::extract(
File_Archive::read("archive.tgz/"),
File_Archive::toFiles("wiki.d/")
);
}
}
?>
</BODY>@]
[[~davidof]] September 3, 2005 at 4:44pm
This doesn't work properly with wikifarms. Making a backup will save the zip file in the chosen directory. Making a backup from more than one farm at once will overwrite the precedent backup
[[~kt007]] March 13, 2005, at 10:34 AM~
I'll try to solve the problem in a next version with will allow to backup wiki.d or files directory or both, adding a password protection too. For Farm i have to set a simply local one to test it, but casue the libray used to zip files allow appending too it's just an option to add to the command line or in the internal option configuration. Thanks for the note.
[[~SteveAgl]] March 13, 2005, at 11:10 AM
This seems to always generate a zip file regardless of the extension specified. Looks like the code should switch on the format to determine the archive class to use instead of always using @@zip_file@@. Also, the link generated for $@@`ShowLink@@ was incorrect; I fixed it with the following:
[=
If ($ShowLink) {
$BackupUrl = preg_replace('#/[^/]*$#',"$BackupDir",$ScriptUrl,1); # use instead of $ScriptUrl.$BackupDir
echo "<br /><br />You can download the backup file now:
<a href='".$BackupUrl.$BackupFile.$BackupFormat."'>".$BackupUrl.$BackupFile.$BackupFormat."</a>";
} =]
[[~KevinWatts]] April 15, 2005, at 11:52 PM
It would be usefull if one could specify just a directory, i.e. the root directory of the wiki, and the scripts stuffs all subdirectories excluding the archive directory itself to make a complete snapshot of a wiki including the scripts, cookbook etc.
[[~Schlaefer]] April 17, 2005, at 05:51 AM
If your wiki's name has a space in it, your zip-file will have this space in its name, too. This max be a problem, because some FTP-clients (e.g. `SmartFTP) won't do anything with such files (neither deleting nor renaming nor downloading). The solution is simple:
[=
If ($DateFormat = 1 ) {
SDV($BackupFile, str_replace(" ","",$WikiTitle)."_".date ("m-d-Y"));
} else {
SDV($BackupFile, str_replace(" ","",$WikiTitle)."_".date ("d-m-Y"));
} =]
[[~JustusvV]] June 14, 2005, at 08:54 AM
The Farm issue could be fixed changing the next lines
# Set the local path to backup directory
//SDV($BackupDirPath,$FarmD.$BackupDir);
SDV($BackupDirPath,$_SERVER[DOCUMENT_ROOT].$BackupDir); //for Farm
In my opinion this Cookbook receip should require the admin password
The spaces are not the only issue in archive name [='`=] could cause issues
[[~Isidor]]
To protect this cookbook and only alow admin to backup the wiki, you can add these lines :
[=
if (strpos($DefaultPasswords['admin'],$GLOBALS[authid])!==FALSE)
{
//Current Cookbook code here.
}
=]
[[~Chumalgare]]
!!!Contributor
[[~SteveAgl]] - Original script author
[[~Nicolas]] - backup all useful directories
Category: [[!Administration]]