[Script] MyBB Zapper - a must-have for developers and admins - RFC
A tool for reconfiguring, cloning and zapping MyBB installations.

If you need an exact clone of the installation, be it for making another forum or just for testing to avoid breaking a production installation, you will probably like mybb-zapper.
It saves you the work of repeating all the tedious work of configuring and tailoring another MyBB installation.
You can also use mybb-zapper for post-install tightening an existing installation, recovering from a breach or preventing such at all.

mybb-zapper allows you to change
  • MySQL hostname, database name, database prefix, username, password
  • MyBB board URL, cookie domain, home URL, admin name, admin dir, super admins, secret PIN
It takes care of backing up the forum database, the config.php and the settings.php files before modifying those according to your commands.

The optional "zap" functionality clears all users except the admin (uid=1), all messages, threads, announcements and the like. You have sort of fully-configured virgin board after applying this.
You need this if you have a forum, want to make another one that resembles a virgin sibling, which you can easily and efficiently tailor (i.e. adapt the categories/forums to the new target group and the like) to your needs. (Note: The cloning and setup of the virtual host/VM itself is not covered here, as this depends of the system you use. If you have basic knowledge of system administration, you'll will know how to do this anyway.)

The mybb-zapper script is very easy to use.
First, download it from Github.
Place it in a directory not accessible from the web. You probably won't want to make mybb-zapper accessible to visitors of your forum. Thus mybb-zapper will attempt to delete itself if it detects being run from a web-accessible directory.
Before you run the script make sure to stop httpd. If pages are serviced while the conversions run, this might result in errors and possibly an inconsistent database.
After you restarted httpd, please rebuild the caches using the ACP. And, voila!

The command line options are
  -h, --help                show help and exit
  -V, --version             show version and exit
  -d DIR, --mybb_dir DIR    root directory of the MyBB installation
  -b DIR, --backup_dir      directory to place backups in
  -s, --simulate            Simulate: do not do change config
  --verbose                 display the actual commands being executed
A few usage examples:

  # mybb-zapper -d webroot
    shows the current configuration of the MyBB installation which is
    in sub directory 'webroot' of the current directory.

  # mybb-zapper -d webroot -b mybbbackups
    Does a full run, backup the original files in the 'mybbbackups' sub
    directory of the current directory. The backup directory specified,
    in this case 'mybbbackups', must exist and be writable.

  # mybb-zapper -d webroot -b . -s --verbose
    Simulation run. Lets you enter.change a configuration and see the SQL
    commands that would be run when not simulating, without actually
    making changes to the database or configuration files.
Here is a walk-through example how the script works:
(The user input is shown in red letters.)

Quote:# perl mybb-zapper.pl -d webspace/forum.thisdomain.org -b backups
MySQL hostname:       'localhost'
MySQL database name:  'my_mybb_database'
MySQL database type:  'mysqli'
MySQL database prefix:'mybb_'
MySQL username:       'mybb_sqluser'
MySQL password:       'MY_OLD_PASSWORD'
MyBB board URL:       'https://forum.thisdomain.org'
MyBB cookie domain:   '.forum.thisdomain.org'
MyBB home URL:        'https://forum.thisdomain.org/index.php'
MyBB admin name:      'mybb_admin'
MyBB admin dir:       'admin'
MyBB super admins:    '1'
MyBB secret PIN:      '1234'
MyBB encoding:        'utf8'
As next step you can (optionally) change the configuration. Continue ? [yN] y

Now the script will show you the current configuration values one-by-one
and ask you for the values you want to change them to. To leave a value
unchanged, just hit 'Enter'. After all configuration values have been changed,
you will be shown the changes and asked for confirmation to convert the
database to the new values. Only then permanent changes will be made.
The old hostname is <localhost>.
Enter a new hostname:
The old database name is <my_mybb_database>.
Enter a new database name: n3wD4t4b4s3
The old database password is <MY_OLD_PASSWORD>.
Enter a new database password: kdnvr83ms9fghm9aen49b
The old database prefix is <mybb_>.
Enter a new database prefix: rdvfmrith349evr
The old database username is <mybb_sqluser>.
Enter a new database username: o239vdfnad9
The old super admin(s) is <1>.
Enter a new super admin(s):
The old admin name is <mybb_admin>.
Enter a new admin name: godzilla
The old admin directory is <admin>.
Enter a new admin directory: berf34rbh
The old Secret PIN is <1234>.
Enter a new Secret PIN: 83474237
The old BB URL is <https://forum.thisdomain.org>.
Enter a new BB URL: https://forum.myclonedforum.org

This is the summary of the changes you entered:
MyBB hostname:       'localhost' [unchanged]
MyBB database name:   'my_mybb_database' --> 'n3wD4t4b4s3'
MyBB database prefix:'mybb_' --> 'rdvfmrith349evr'
MyBB password:       'MY_OLD_PASSWORD' --> 'kdnvr83ms9fghm9aen49b'
MyBB board URL:      'https://forum.thisdomain.org' --> 'https://forum.myclonedforum.org'
MyBB cookie domain:  '.forum.thisdomain.org' --> '.forum.myclonedforum.org'
MyBB home URL:       'https://forum.thisdomain.org/index.php' --> 'https://forum.myclonedforum.org/index.php'
MyBB admin name:     'mybb_admin' --> 'godzilla'
MyBB admin dir:      'admin' --> 'berf34rbh'
MyBB super admins:   '1' [unchanged]
MyBB secret PIN:     '1234' --> '83474237'
Do you accept these changes? [yN] y

Now the database and configuration files will be backed up and then modified
so they match the changes you specified. Continue? [yN] y
Creating backup file backups/mybb_backup_db_2016-10-06-21-22-03 using the command:
<mysqldump --defaults-extra-file=VZIEbEtYeKHO -h localhost -u mybb_sqluser --add-drop-database --add-drop-table --routines my_mybb_database>
 Please wait...
Finished creating database backup.
Backing up config.php.
Backing up settings.php.

Now you have the option to zap the database from all threads, posts, users
(leaving only the admin user) etc. So that you get an exact fresh clone of
your board with all configuration things kept from the original one.
Do you want to zap the database? [yN] y
Zapping the database... please wait.
Copying DB. Please wait...
Copying DB back. Please wait...
mybb-zapper.pl: Finished.

If you find the script useful, please consider giving the developer a treat by clicking the "Rate" button Cool

Questions and feedback welcome.
Have fun! Smile
[Image: yudvab50.jpg]
Interesting concept, I will use it someday in the near future to test some plugins which are too dangerous to be installed directly on my site.
[Image: fSGNVQj.png]

Forum Jump:

Users browsing this thread: 1 Guest(s)