Index: src/main/java/com/xpn/xwiki/plugin/packaging/Package.java
===================================================================
--- src/main/java/com/xpn/xwiki/plugin/packaging/Package.java	(revision 19300)
+++ src/main/java/com/xpn/xwiki/plugin/packaging/Package.java	(working copy)
@@ -31,6 +31,7 @@
 import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Date;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
 import java.util.zip.ZipOutputStream;
@@ -564,41 +565,69 @@
         }
         if (status == DocumentInfo.INSTALL_OK || status == DocumentInfo.INSTALL_ALREADY_EXIST
             && doc.getAction() == DocumentInfo.ACTION_OVERWRITE) {
+            XWikiDocument previousdoc = null;
             if (status == DocumentInfo.INSTALL_ALREADY_EXIST) {
-                XWikiDocument deleteddoc = context.getWiki().getDocument(doc.getFullName(), context);
+                previousdoc = context.getWiki().getDocument(doc.getFullName(), context);
                 // if this document is a translation: we should only delete the translation
                 if (doc.getDoc().getTranslation() != 0) {
-                    deleteddoc = deleteddoc.getTranslatedDocument(doc.getLanguage(), context);
+                    previousdoc = previousdoc.getTranslatedDocument(doc.getLanguage(), context);
                 }
-                try {
+                // we should only delete the previous document 
+                // if we are overridding the versions and/or if this is a backup pack
+                if (this.withVersions||this.backupPack) {
+                 try {
                     // This is not a real document delete, it's a upgrade. To be sure to not
                     // generate DELETE notification we directly use {@link XWikiStoreInterface}
-                    context.getWiki().getStore().deleteXWikiDoc(deleteddoc, context);
-                } catch (Exception e) {
+                    context.getWiki().getStore().deleteXWikiDoc(previousdoc, context);
+                 } catch (Exception e) {
                     // let's log the error but not stop
                     result = DocumentInfo.INSTALL_ERROR;
                     addToErrors(doc.getFullName() + ":" + doc.getLanguage(), context);
                     if (LOG.isErrorEnabled()) {
-                        LOG.error("Failed to delete document " + deleteddoc.getFullName());
+                        LOG.error("Failed to delete document " + previousdoc.getFullName());
                     }
                     if (LOG.isDebugEnabled()) {
-                        LOG.debug("Failed to delete document " + deleteddoc.getFullName(), e);
+                        LOG.debug("Failed to delete document " + previousdoc.getFullName(), e);
                     }
+                 }
                 }
             }
             try {
                 if (!this.backupPack) {
+                    // if the import is not a backup pack with set the user to the importing user
                     doc.getDoc().setAuthor(context.getUser());
+                    doc.getDoc().setContentAuthor(context.getUser());
+                    // if the import is not a backup pack we set the date to now
+                    Date date = new Date();
+                    doc.getDoc().setDate(date);
+                    doc.getDoc().setContentUpdateDate(date);
                 }
 
                 if ((!this.preserveVersion) && (!this.withVersions)) {
                     doc.getDoc().setVersion("1.1");
                 }
 
-                // We don't want date and version to change
-                // So we need to cancel the dirty status
-                doc.getDoc().setContentDirty(false);
-                doc.getDoc().setMetaDataDirty(false);
+                if (!this.withVersions && !this.backupPack) {
+                	// If it is not a backup pack and we are not overriding the versions
+                	// then we want to insert the archive from the original doc
+                	doc.getDoc().setDocumentArchive(previousdoc.getDocumentArchive(context));
+                } else {
+
+                	// if there was not archive in the source package
+                	// then we should reset the version number to 1.1
+                	if ((doc.getDoc().getDocumentArchive() == null)
+                			|| (doc.getDoc().getDocumentArchive().getNodes() == null)
+                			|| (doc.getDoc().getDocumentArchive().getNodes().size()==0)) {
+                		doc.getDoc().setVersion("1.1");
+                	}
+
+                	// We don't want date and version to change
+                	// So we need to cancel the dirty status
+                	doc.getDoc().setContentDirty(false);
+                	doc.getDoc().setMetaDataDirty(false);
+                }
+                
+                // Attachment saving should not generate additional saving
                 for (XWikiAttachment xa : doc.getDoc().getAttachmentList()) {
                     xa.setMetaDataDirty(false);
                     xa.getAttachment_content().setContentDirty(false);
@@ -615,11 +644,12 @@
                             doc.getDoc().getDocumentArchive(context), true, context);
                     }
                 }
+
                 // if there is no archive in xml and content&metaData Dirty is not set
-                // then archive was not saved
-                // so we need save it via resetArchive
+                // then archive was not saved so we need save it via resetArchive
                 if ((doc.getDoc().getDocumentArchive() == null)
-                    || (doc.getDoc().getDocumentArchive().getNodes() == null) || (!this.withVersions)) {
+                    || (doc.getDoc().getDocumentArchive().getNodes() == null)
+                    || (doc.getDoc().getDocumentArchive().getNodes().size()==0)) {
                     doc.getDoc().resetArchive(context);
                 }
             } catch (XWikiException e) {
