Index: include/utils/misc.h
===================================================================
--- include/utils/misc.h	(revision 8231)
+++ include/utils/misc.h	(working copy)
@@ -244,14 +244,11 @@
     PGICON_PUBLIC
 };
 
-#endif // PGSCLI
-
-#endif
-
-#if !defined(PGSCLI)
-
 // File/directory name cleanup
 wxString sanitizePath(const wxString &path);
-wxString commandLineCleanOption(const wxString &option);
+wxString commandLineCleanOption(const wxString &option, bool schemaObject = false);
 
 #endif // PGSCLI
+
+#endif
+
Index: frm/frmBackupServer.cpp
===================================================================
--- frm/frmBackupServer.cpp	(revision 8231)
+++ frm/frmBackupServer.cpp	(working copy)
@@ -143,7 +143,7 @@
         cmd += wxT(" --host ") + server->GetName();
 
     cmd +=  wxT(" --port ") + NumToStr((long)server->GetPort())
-         +  wxT(" --username ") + commandLineCleanOption(server->GetUsername());
+         +  wxT(" --username ") + commandLineCleanOption(qtIdent(server->GetUsername()));
     return cmd;
 }
 
Index: frm/frmBackup.cpp
===================================================================
--- frm/frmBackup.cpp	(revision 8231)
+++ frm/frmBackup.cpp	(working copy)
@@ -198,7 +198,7 @@
         cmd += wxT(" --host ") + server->GetName();
 
     cmd +=  wxT(" --port ") + NumToStr((long)server->GetPort())
-         +  wxT(" --username ") + commandLineCleanOption(server->GetUsername());
+         +  wxT(" --username ") + commandLineCleanOption(qtIdent(server->GetUsername()));
 
     if (object->GetConnection()->GetIsGreenplum())
         cmd += wxT(" --gp-syntax ");
@@ -272,31 +272,22 @@
     cmd.Append(wxT(" --file \"") + txtFilename->GetValue() + wxT("\""));
 
     if (object->GetMetaType() == PGM_SCHEMA)
-#ifdef WIN32
-        cmd.Append(wxT(" --schema ") + commandLineCleanOption(wxT("\"") + ((pgSchema*)object)->GetIdentifier() + wxT("\"")));
-#else
-        cmd.Append(wxT(" --schema ") + commandLineCleanOption(wxT("'") + ((pgSchema*)object)->GetQuotedIdentifier() + wxT("'")));
-#endif
+        cmd.Append(wxT(" --schema ") + commandLineCleanOption(((pgSchema*)object)->GetQuotedIdentifier(), true));
 
     else if (object->GetMetaType() == PGM_TABLE || object->GetMetaType() == GP_PARTITION) 
     {
         // The syntax changed in 8.2 :-(
         if (pgAppMinimumVersion(backupExecutable, 8, 2))
         {
-#ifdef WIN32
             cmd.Append(wxT(" --table ") +
-                  commandLineCleanOption(wxT("\"\"") + ((pgTable*)object)->GetSchema()->GetIdentifier() + 
-                        wxT("\".\"") + ((pgTable*)object)->GetIdentifier() + wxT("\"\"")));
-#else
-            cmd.Append(wxT(" --table ") +
-                  commandLineCleanOption(wxT("'") + ((pgTable*)object)->GetSchema()->GetQuotedIdentifier() + 
-                        wxT(".") + ((pgTable*)object)->GetQuotedIdentifier() + wxT("'")));
-#endif
+                  commandLineCleanOption(((pgTable*)object)->GetSchema()->GetQuotedIdentifier(), true) + 
+                  wxT(".") +
+                  commandLineCleanOption(((pgTable*)object)->GetQuotedIdentifier(), true));
         }
         else
         {
-            cmd.Append(wxT(" --table ") + commandLineCleanOption(((pgTable*)object)->GetQuotedIdentifier()));
-            cmd.Append(wxT(" --schema ") + commandLineCleanOption(((pgTable*)object)->GetSchema()->GetQuotedIdentifier()));
+            cmd.Append(wxT(" --table ") + commandLineCleanOption(((pgTable*)object)->GetQuotedIdentifier(), true));
+            cmd.Append(wxT(" --schema ") + commandLineCleanOption(((pgTable*)object)->GetSchema()->GetQuotedIdentifier(), true));
         }
     }
 
Index: frm/frmBackupGlobals.cpp
===================================================================
--- frm/frmBackupGlobals.cpp	(revision 8231)
+++ frm/frmBackupGlobals.cpp	(working copy)
@@ -158,7 +158,7 @@
         cmd += wxT(" --host ") + server->GetName();
 
     cmd +=  wxT(" --port ") + NumToStr((long)server->GetPort())
-         +  wxT(" --username ") + commandLineCleanOption(server->GetUsername());
+         +  wxT(" --username ") + commandLineCleanOption(qtIdent(server->GetUsername()));
     return cmd;
 }
 
Index: frm/frmRestore.cpp
===================================================================
--- frm/frmRestore.cpp	(revision 8231)
+++ frm/frmRestore.cpp	(working copy)
@@ -338,19 +338,19 @@
                 {
                     int sel=lstContents->GetSelection();
                     if (lstContents->GetText(sel, 0).Lower() == wxString(_("Function")).Lower())
-                        cmd.Append(wxT(" --function ") + commandLineCleanOption(qtIdent(lstContents->GetText(sel, 1).BeforeLast('('))));
+                        cmd.Append(wxT(" --function ") + commandLineCleanOption(qtIdent(lstContents->GetText(sel, 1).BeforeLast('(')), true));
                     else if (lstContents->GetText(sel, 0).Lower() == wxString(_("Table")).Lower())
-                        cmd.Append(wxT(" --table ") + commandLineCleanOption(qtIdent(lstContents->GetText(sel, 1))));
+                        cmd.Append(wxT(" --table ") + commandLineCleanOption(qtIdent(lstContents->GetText(sel, 1)), true));
                     else
                         return wxT("restore: internal pgadmin error.");   // shouldn't happen!
 
                     break;
                 }
                 case PGM_TABLE:
-                    cmd.Append(wxT(" --table ") + commandLineCleanOption(object->GetQuotedIdentifier()));
+                    cmd.Append(wxT(" --table ") + commandLineCleanOption(object->GetQuotedIdentifier(), true));
                     break;
                 case PGM_FUNCTION:
-                    cmd.Append(wxT(" --function ") + commandLineCleanOption(object->GetQuotedIdentifier()));
+                    cmd.Append(wxT(" --function ") + commandLineCleanOption(object->GetQuotedIdentifier(), true));
                     break;
                 default:
                     break;
Index: utils/misc.cpp
===================================================================
--- utils/misc.cpp	(revision 8231)
+++ utils/misc.cpp	(working copy)
@@ -1238,35 +1238,50 @@
     return wxEmptyString;
 }
 
-// Fixup a (quoted) string for use on the command line
-wxString commandLineCleanOption(const wxString &option)
+/**
+ * FUNCTION: commandLineCleanOption
+ * INPUTS:
+ *       option       - input string needs to be reformatted
+ *       schemaObject - Is this an object related to schema?
+ * PURPOSE:
+ *  - Fixup a (double-quoted) string for use on the command line
+ *
+ *    1. Schema objects needs three (slash & double-quote) combination
+ *       instead of a double-quote to be used as a command-line option
+ *    2. Options other than the schema objects needs (slash & double-quote)
+ *       combination instead of a double-quote to be used as a command-line
+ *       option.
+ *
+ *    i.e. CASE: Dump a table named em"p and database name tes"t having username
+ *         xy\z. The command-line arguments for these values will be as below:
+ *
+ *         pg_dump --username "xy\\z" --table public."em\"\"\"p" "tes\"t"
+ *
+ */
+wxString commandLineCleanOption(const wxString &option, bool schemaObject)
 {
-    wxString tmp;
-    bool wasQuoted = false;
+    wxString tmp = option;
 
+    // Only double-quoted string needs to be formatted
     if (option.StartsWith(wxT("\"")) && option.EndsWith(wxT("\"")))
     {
         tmp = option.AfterFirst((wxChar)'"').BeforeLast((wxChar)'"');
-        wasQuoted = true;
-    }
-    else
-        tmp = option;
 
-#ifdef __WXMSW__
-    if (wasQuoted)
-        tmp.Replace(wxT("\"\""), wxT("\"\"\""));
-    else
-    {
-        tmp.Replace(wxT("\""), wxT("\"\""));
+        // Replace single splash to double-splash
         tmp.Replace(wxT("\\"), wxT("\\\\"));
-    }
-#else
-    tmp.Replace(wxT("\\"), wxT("\\\\"));
-    tmp.Replace(wxT("\"\""), wxT("\\\""));
-#endif
 
-    if (wasQuoted)
+        // Replace double-quote with slash & double-quote
+        tmp.Replace(wxT("\""), wxT("\\\""));
+
+        if (!schemaObject)
+            // Replace double (slash & double-quote) combination to single (slash & double-quote) combination
+            tmp.Replace(wxT("\\\"\\\""), wxT("\\\""));
+        else
+            // Replace double (slash & double-quote) combination to triple (slash & double-quote) combination
+            tmp.Replace(wxT("\\\"\\\""), wxT("\\\"\\\"\\\""));
+
         tmp = wxT("\"") + tmp + wxT("\"");
+    }
 
     return tmp;
 }
