GetSimple Support Forum

Full Version: Exclude some dirs from site backups or backup GS only
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In my home dir at hosting I have not only GS site, but a little bit of other directories. I dont need to backup this dirs into GS-site backup. Is it possible to "say" for backup module to exclude some dir, or backup only GS directories?
You shouldn't have other directories in-side the GS home.
shawn_a Wrote:You shouldn't have other directories in-side the GS home.
But I can`t! I have external (google, forums, etc...) links to my files in root or its subdirs which I must preserve.
Developer exactly know GS directories, and backup procedure must backup only this GS files and down to its subdirs. As for any other dirs - user must have an ability to add them to the GS-system backup. It is common practice Wink
Just imagine: I want to backup my folder Documents and Settings from disk C:, but backup procceed entire disc C - Smile))))
yojoe Wrote:http://get-simple.info/extend/plugin/sim...ckups/394/
This is better, but I must prepare nearly 5 different sources and sequentialy run them.... Sad
there is a risk to obtain nonconsistent set of backups (if I forgot to get buckup of some sources). One backup of CMScore + userData + userDirs is much more preferable.
I don't see a problem.
Only thing you have to backup is /data directory.
If you need to migrate to other host, just install a fresh GS instance with all plugins, and unpack /data from backup. Nothing more to do.

But if you need to create a custom backup, then prepare a small php script, and call zip packer with exec command. There are dozen ways of creating and maintaining backups, and since you need a heavily customized/sophisticated methods, then built-in GS solutions doesn't meet your requirements.
yojoe Wrote:I don't see a problem.
My problem: I am not so familiar with PHP to do it by myself. That is why I am looking for ready to use plugin with a simplest functionality: set up folders to backup (in a text box where folders and files listed line by line, or chekmarks in some file/folders browser) and 2 buttons (backup and restore with ability to select backup file to restore it). that's all Wink
so.... If you want to get something - do it yourself Smile
here is my modifications to the file admin\zip.php. I remove directories controls (to obtain all files)

Code:
foreach($iter as $element) {
/* @var $element SplFileInfo */
$dir = str_replace($sourcePath, '', $element->getPath()) . '/';
//------------- zencoder 2012.05.27 - backup selected directories only -------------
//if (strstr($dir,$GSADMIN.DIRECTORY_SEPARATOR) || strstr($dir,'backups'.DIRECTORY_SEPARATOR)) {
//  #don't archive these folders
//} else if ($element->getFilename() != '..') { // FIX: if added to ignore parent directories
if ($element->getFilename() != '..') { // FIX: if added to ignore parent directories
// ------------- zencoder 2012.05.27 - backup selected directories only -------------
and add filter by file name mask just before command to pack file into backup.
Code:
// add file to archive
// ------------- zencoder 2012.05.27 - backup selected directories only -------------
// http://get-simple.info/wiki/how_to:backup_website?s[]=backup
if (
    strpos($file, 'data'.DIRECTORY_SEPARATOR ) == strlen(GSROOTPATH) ||
    strpos($file, 'admin'.DIRECTORY_SEPARATOR ) == strlen(GSROOTPATH) ||
    strpos($file, 'theme'.DIRECTORY_SEPARATOR ) == strlen(GSROOTPATH) ||
    strpos($file, 'plugins'.DIRECTORY_SEPARATOR ) == strlen(GSROOTPATH) ||
    // this is my folder outside GS which I want to be included into backup
    strpos($file, 'uploads'.DIRECTORY_SEPARATOR ) == strlen(GSROOTPATH)
   )  
// ------------- zencoder 2012.05.27 - backup selected directories only -------------
$archiv->addFile($file, $fileInArchiv);


My knowlege of PHP is slightly greater than zero, so code is ugly, but its work right as I need.
Can anybody write this more clearly?
It seems to me that directories (internal GS and users external like my uploads) included into backup must be defined like GSROOTPATH somewhere in gsconfig.php to be an universal solution.
After I found and propose some modification to zip.php to make backups more sharp, there are second release is out, but my solution is not implemented yet Sad

Is it possible to include it (in some beter code) in 3.1.3 version?
I have modified the file admin/zip.php. That file has the next line of code:

if ( strstr($dir, $GSADMIN.DIRECTORY_SEPARATOR )
|| strstr($dir, 'backups'.DIRECTORY_SEPARATOR )) {

I just added the other folder I want to skip:

if ( strstr($dir, $GSADMIN.DIRECTORY_SEPARATOR )
|| strstr($dir, 'backups'.DIRECTORY_SEPARATOR )
|| strstr($dir, 'Name of the folder to skip'.DIRECTORY_SEPARATOR )) {

It is working perfectly.