Post by vimal » Thu Sep 03, 2009 8:14 pm

Hi All,

I was wondering about a few things.

1. Is it possible to upload all the products, descriptions etc offline (local server using xampp) then set up opencart on live server via ftp and restore the database to get the shop loaded and ready to go?

2. How to back up the database?
I have tried admin/configuration/backup-restore. Got an error as below

Error: Unknown database ''opencart'
Error No: 1049
SHOW TABLES FROM `'opencart`

3. Is there a step by step guide to show the above 2 points on how it is done?

Thanks in advance!
Vimal.

www.beeshop.se
Starta webbshop, Starta e-butik, Starta e-handel


Active Member

Posts

Joined
Wed Aug 26, 2009 8:54 am
Location - Sweden

Post by nzjolly » Fri Sep 04, 2009 4:18 am

2. How to back up the database?
I have tried admin/configuration/backup-restore. Got an error as below

Error: Unknown database ''opencart'
Error No: 1049
SHOW TABLES FROM `'opencart`

yep, you can do a restore from local to live (this is what i do)

and yep you need to apply a small fix to solve the above database backup error,
i will see if i can dig out the post that tells you how to fix it (for the live of me i cannot remember just at the min)
its not much its just a removal of an additional quote ' inside one of the files.

New member

Posts

Joined
Tue Sep 01, 2009 6:52 am

Post by nzjolly » Fri Sep 04, 2009 4:24 am

Error: Access denied for user 'username'@'hostname' to database ''databasename'
Error No: 1044
SHOW TABLES FROM `'databasename`

However, a quick look at /admin/model/tool/backup.php revealed a single quote that simply needed to be removed, to make the Backup function work (for me). I changed Line 16 from...

Code: Select all
$table_query = $this->db->query("SHOW TABLES FROM `'" . DB_DATABASE . "`");


to...

Code: Select all
$table_query = $this->db->query("SHOW TABLES FROM `" . DB_DATABASE . "`");


Note the extra single quote just before " . DB_DATABASE

New member

Posts

Joined
Tue Sep 01, 2009 6:52 am

Post by nzjolly » Fri Sep 04, 2009 4:26 am

now with the database, all i did was set-up the local server with a new database, backup from the live, and restore to the local. using the admin interface. (someone may have a better way i dunno) but this is what i do and it seems to work for me.

you could also look at the import and export plug-in

New member

Posts

Joined
Tue Sep 01, 2009 6:52 am

Post by vimal » Fri Sep 04, 2009 3:23 pm

Hi nzjolly

Thanks for your reply. I checked the solution that you suggested. I don't have an extra quote. So the file is correct.

I think the errors are different. Mine is 1049 and the solution is for 1044

www.beeshop.se
Starta webbshop, Starta e-butik, Starta e-handel


Active Member

Posts

Joined
Wed Aug 26, 2009 8:54 am
Location - Sweden

Post by JNeuhoff » Fri Sep 04, 2009 7:31 pm

If it is of any help, I am using this admin/model/tool/backup.php file, with some fixes, for OpenCart 1.3.2:

Code: Select all

<?php
class ModelToolBackup extends Model {
	public function restore($sql) {
		foreach (explode(";\n", $sql) as $sql) {
    		$sql = trim($sql);
    		
			if ($sql) {
      			$this->db->query($sql);
    		}
  		}
	}
	
	public function backup() {
		$output = '';
		
		$table_query = $this->db->query("SHOW TABLES FROM `" . DB_DATABASE ."`");

		foreach ($table_query->rows as $table) {
			if (DB_PREFIX) {
				if (strpos($table['Tables_in_' . DB_DATABASE], DB_PREFIX) === FALSE) {
					$status = FALSE;
				} else {
					$status = TRUE;
				}
			} else {
				$status = TRUE;
			}
			
			if ($status) {
				$output .= 'TRUNCATE TABLE `' . $table['Tables_in_' . DB_DATABASE] . '`;' . "\n\n";
			
				$query = $this->db->query("SELECT * FROM `" . $table['Tables_in_' . DB_DATABASE] . "`");
				
				foreach ($query->rows as $result) {
					$fields = '';
					
					foreach (array_keys($result) as $value) {
						$fields .= '`' . $value . '`, ';
					}
					
					$values = '';
					
					foreach (array_values($result) as $value) {
						$value = str_replace(array("\x00", "\x0a", "\x0d", "\x1a"), array('\0', '\n', '\r', '\Z'), $value);
						$value = str_replace(array("\n", "\r", "\t"), array('\n', '\r', '\t'), $value);
						$value = str_replace('\\', '\\\\',	$value);
						$value = str_replace('\'', '\\\'',	$value);
						$value = str_replace('\\\n', '\n',	$value);
						$value = str_replace('\\\r', '\r',	$value);
						$value = str_replace('\\\t', '\t',	$value);			
						
						$values .= '\'' . $value . '\', ';
					}
					
					$output .= 'INSERT INTO `' . $table['Tables_in_' . DB_DATABASE] . '` (' . preg_replace('/, $/', '', $fields) . ') VALUES (' . preg_replace('/, $/', '', $values) . ');' . "\n";
				}
				
				$output .= "\n\n";
			}
		}

		return $output;	
	}
}
?>

Override Engine * Integrated VQMod * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Rich Snippets * Google Tag Manager * Export/Import Tool * SpamBot Buster * Survey Plus


User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by vimal » Fri Sep 04, 2009 8:01 pm

Thank you so much JNeuhoff. It works like charm!!

www.beeshop.se
Starta webbshop, Starta e-butik, Starta e-handel


Active Member

Posts

Joined
Wed Aug 26, 2009 8:54 am
Location - Sweden

Post by Skyhigh » Sat Sep 12, 2009 4:03 pm

Removing the extra quote in the backup.php file worked for me!

LoveMoissanite.com - Moissanite Rings - Proudly Powered by Opencart
[How To] Speed Up Page Content with Opencart - Opencart advocate since 2009


New member

Posts

Joined
Fri Sep 11, 2009 8:12 pm

Post by decavolt » Thu Sep 24, 2009 1:55 am

Quick question - when using this to Restore, does it merge data or overwrite?

Newbie

Posts

Joined
Tue Aug 18, 2009 9:35 am

Post by vimal » Thu Sep 24, 2009 9:51 pm

I have done restore and it overwrites. So the new info is lost. It reverts back to your restored file.

www.beeshop.se
Starta webbshop, Starta e-butik, Starta e-handel


Active Member

Posts

Joined
Wed Aug 26, 2009 8:54 am
Location - Sweden
Who is online

Users browsing this forum: No registered users and 12 guests