Nico Knoll Posted January 23, 2013 Share Posted January 23, 2013 Hi, is there a way to "reset" PW to the point after the installation? Because it is kind of annoying to reinstall PW everytime I develope a new module or theme or template or whatever... It would be lovely to just click a button and bamm: A fresh clean PW installation. Is there a way or what's your practice? Greets, Nico Link to comment Share on other sites More sharing options...
Joss Posted January 23, 2013 Share Posted January 23, 2013 I must admit that I have an installation that I simply use for trying things out. It is useful because as I try the next thing, I have plenty of examples of other stuff to make sure it all works together. Lots of broken and tatty bits too - but it all adds to the flavour. What you probably want is a profile with your favourite modules pre-loaded, quite a few test pages, repeater fields, assorted image fields and so on (so, a typical site) then use that as a test bed. Link to comment Share on other sites More sharing options...
netcarver Posted January 23, 2013 Share Posted January 23, 2013 (edited) @Nico There are a few ways to do this. One would be to setup a simple LAMP stack with an unused PW install in a virtual machine using KVM/QEMU or VirtualBox. etc Take a snapshot of the virtual machine just after you do a fresh PW install. You can then just restore the snapshot everytime you want to start over. If you want to keep the state of your work you can just clone the installation to a new VM and then restore your initial one. Personally I just use a bash script for "one-click" installations of PW (or other software I'm testing). I have it do this... Ask for the the domain name to use Ask what software to install Add an entry to my /etc/hosts file Create the root directory for the new site Create a new virtual host pointing to the root dir Restart Apache Create an application specific MySQL user + DB + password combo Install the software I've asked it to (for some software I use a lot) automate the initial setup screens using wget to post the correct params into the app. If anyone's interested I could gist various PW specific parts of my script. (Go easy though, I'm just learning bash scripting.) Edited to add: Vagrant is definitely worth taking a look at for this kind of thing too. Edited January 23, 2013 by netcarver 2 Link to comment Share on other sites More sharing options...
Nico Knoll Posted January 23, 2013 Author Share Posted January 23, 2013 Well what I want is to click one button/start one script to reset the database and one folder to a specific point. I'm using XAMPP on Mac. So what I guess I need is: a folder with a clean installation which will be duplicated and overwrites the other folder everytime I start this script. And a way to automatically clean a database and import a given .sql file (which I've exported from the clean installation). Would be lovely to have a batch file doing this but I don't know how to make a batch file... Link to comment Share on other sites More sharing options...
Nico Knoll Posted January 23, 2013 Author Share Posted January 23, 2013 So I guess it could be a php script too: Kind of: <?php // code for delete the site folder // code for copying the clean site folder // code for mysql connection // code for delete a table // code for cloning a table and renaming it ?> Link to comment Share on other sites More sharing options...
netcarver Posted January 23, 2013 Share Posted January 23, 2013 Yeah, actually you could do it with PHP if you wanted. Link to comment Share on other sites More sharing options...
Soma Posted January 23, 2013 Share Posted January 23, 2013 I have a shell script to do a copy of an install to copy files and db. I only use this to dev live copy the current state. For developement and testing i only use 1 or 2 installs i have since a year. No need to install a new pw just for creating a new module or theme. So dont understand your need to do so. Link to comment Share on other sites More sharing options...
Nico Knoll Posted January 23, 2013 Author Share Posted January 23, 2013 I just don't like start developing in a messed up installation :/ Link to comment Share on other sites More sharing options...
Soma Posted January 23, 2013 Share Posted January 23, 2013 Theyre not messed up at all more a slick playing ground which also helps spotting possible issues with other modules an upgrade paths. What you could do is let the installer there and just clean db and files and run installer again. Or use shell script to quickly rsync and copy a clean install over your existing. If you want to start new module or theme you can also spend 1 minute to create clean install. Link to comment Share on other sites More sharing options...
Joss Posted January 23, 2013 Share Posted January 23, 2013 I agree - I like to make sure I have lots of Soma's modules installed to see exactly how much trouble I am in .... Link to comment Share on other sites More sharing options...
Nico Knoll Posted January 23, 2013 Author Share Posted January 23, 2013 So, here's my script: <?php require('backup_restore.class.php'); $newImport = new backup_restore('localhost','root','','pw_clean','*'); $newImport->restore(); function SureRemoveDir($dir, $DeleteMe) { if(!$dh = @opendir($dir)) return; while (($obj = readdir($dh))) { if($obj=='.' || $obj=='..') continue; if (!@unlink($dir.'/'.$obj)) SureRemoveDir($dir.'/'.$obj, true); } if ($DeleteMe){ closedir($dh); @rmdir($dir); } } function rcopy($src, $dst) { if (file_exists($dst)) rrmdir($dst); if (is_dir($src)) { mkdir($dst); $files = scandir($src); foreach ($files as $file) if ($file != "." && $file != "..") rcopy("$src/$file", "$dst/$file"); } else if (file_exists($src)) copy($src, $dst); } SureRemoveDir('../pw_clean/site', true); rcopy('site', '../pw_clean/site/'); ?> And it's working well 1 Link to comment Share on other sites More sharing options...
Pete Posted January 23, 2013 Share Posted January 23, 2013 Cool, a link to the backup_restore.php script would be nice too 1 Link to comment Share on other sites More sharing options...
OrganizedFellow Posted March 14, 2013 Share Posted March 14, 2013 So, here's my script: And it's working well Is this still a good solution? I'd be interested in trying it out. Can you also share the backup_restore.class.php file? Link to comment Share on other sites More sharing options...
Recommended Posts