• Does anybody know a solution to make a backup only for a single blog in a multisite installation?

    I have a subdirectories-based network installation, and wish to give a way for each blog administrator to make a backup (DB & files) only for its own blog.

Viewing 15 replies - 1 through 15 (of 35 total)
  • Tools -Export.

    That’s it.

    Thread Starter narcisgarcia

    (@narcisgarcia)

    Thanks, very useful.
    But I don’t find an export way for site preferences and files.

    ou won’t. currently there’s nothing out there to export a single site off a network. it’s everything or the export file.

    you don’t want to give blog users access to the entire db.

    Thread Starter narcisgarcia

    (@narcisgarcia)

    Sure, I don’t want to give blog users access to the entire network data; only to their own data to make it restorable on another WordPress installation.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    The menus and prefs are not the data. The data is your post content and the images. THOSE are exportable.

    Thread Starter narcisgarcia

    (@narcisgarcia)

    I understand as user’s data:
    – Published texts (Posts, Pages, Comments)
    – Attached files (media)
    – Site preferences (menus, selected theme, title, etc.)
    – Plugin preferences and their custom accessory files

    Conclusion: all information and files that single-site administrator could set, write and upload.

    – Site preferences (menus, selected theme, title, etc.)
    – Plugin preferences and their custom accessory files

    these are not included in the Export tool.

    As I said above – there is no plugin that does exactly what you want.

    Thread Starter narcisgarcia

    (@narcisgarcia)

    Then, is there any way to export easily attached files for published contents?

    As I said above – there is no plugin that does exactly what you want.

    I think thats true in all cases lmao.

    @narcisgarcia for each user or just for yourself?

    You could make backups of each by using zipping method.

    class createDirZip extends createZip {
    
    	function get_files_from_folder($directory, $put_into) {
    		if ($handle = opendir($directory)) {
    			while (false !== ($file = readdir($handle))) {
    				if (is_file($directory.$file)) {
    					$fileContents = file_get_contents($directory.$file);
    					$this->addFile($fileContents, $put_into.$file);
    				} elseif ($file != '.' and $file != '..' and is_dir($directory.$file)) {
    					$this->addDirectory($put_into.$file.'/');
    					$this->get_files_from_folder($directory.$file.'/', $put_into.$file.'/');
    				}
    			}
    		}
    		closedir($handle);
    	}
    }

    then

    $createZip = new createDirZip;
    $createZip->addDirectory('uploads/');
    $createZip->get_files_from_folder('/wp-content/uploads/', 'uploads/');

    and

    $fileName = 'tmp/uploadsbackup.zip';
    $fd = fopen ($fileName, 'wb');
    $out = fwrite ($fd, $createZip->getZippedfile());
    fclose ($fd);
    
    $createZip->forceDownload($fileName);
    @unlink($fileName);

    this will take all of the contents of /uploads/ and zip it into “uploadsbackup.zip”

    it might be a pain in the butt to do this for each user but im sure you can alter the code above to do so, find users, and place the username within the get_files_from_folder('".$users."/uploads/ or whatever.

    you could use something like this to grab the usernames in order from newest to oldest and if you place it in a <li> you could have a nice list of all the backups you need to download right away.

    $usernames = $wpdb->get_results("SELECT user_nicename, user_url FROM $wpdb->users ORDER BY ID DESC LIMIT 999");
    foreach ($usernames as $username) {
    $createZip->get_files_from_folder('/".$username->user_nicename."/uploads/', 'uploads/');

    also adding the username to the temp. zip

    $fileName = 'tmp/".$username->user_nicename."backup.zip';

    just depends on how bad you need those backups, and or separated.

    Thread Starter narcisgarcia

    (@narcisgarcia)

    I manage a multisite installation (subdirectory based), and need to give a way for each user (1 user owns 1 sub-site, another user owns another sub-site) to backup own contents.

    Of course I can backup the entire multisite directory and database, but cannot deliver this backup to “user 1” when also contains data from user 2, 3, 4, etc.

    I see that the multisite uploaded files are in /wp-content/blogs.dir/ and I don’t see clear separation between each site correspondence.

    my multi site works as https://domain.com/username/wp-content/uploads/

    you can alter the code above to be specific and add the needed directory for lets say the “uploads” and you could make a generic file for each logged in user

    and you could grab the the URL of each user by doing this:

    $usernames = $wpdb->get_results("SELECT user_nicename, user_url FROM $wpdb->users ORDER BY ID DESC LIMIT 999");
    foreach ($usernames as $username) {
    echo '<li>https://www.yourdomain.com/'.$username->user_nicename.'/wp-content/uploads</li>";

    it will pump out from new to old:

    https://www.yourdomain.com/username10/wp-content/uploads/
    https://www.yourdomain.com/username9/wp-content/uploads/
    https://www.yourdomain.com/username8/wp-content/uploads/
    https://www.yourdomain.com/username7/wp-content/uploads/

    but it will replace the username## with like the username or site name i personally use usernames as the subdir.

    eh, after all this i should just make a plugin that would backup mutli-site users profile, uploads, posts, pages, links, and so on. :X

Viewing 15 replies - 1 through 15 (of 35 total)
  • The topic ‘Separated multisite backups’ is closed to new replies.