Wiki source code of Import/Export

Last modified by Vincent Massol on 2020/01/28

Show last authors
1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc/}}
3 {{/box}}
4
5 This feature allows you to export one or several pages from your wiki into a [[**XAR** file>>extensions:Extension.XAR Module Specifications]] (**X**Wiki **AR**chive) or to import one or several pages from an existing XAR file. This is useful for moving wiki pages from one instance to another or to perform lightweight backup of your wiki pages.
6
7 {{warning}}
8 This feature doesn't replace a [[proper backup>>Backup]].
9 {{/warning}}
10
11 = Importing XWiki pages =
12
13 Prerequisites:
14
15 * {{info}}New in XWiki 5.0+{{/info}} If your wiki is empty and this is your first import, you will need [[to log in as ##superadmin##>>Documentation.AdminGuide.Configuration#HEnablesuperadminaccount]] to do the first import since there are no users defined in the wiki at this time.
16 * A configured database and Servlet Container. If you don't have them, see the [[Installation guide>>Documentation.AdminGuide.Installation]].
17
18 Follow these steps:
19
20 * Ensure your database and container are started
21 * Got the Administration page (top right Drawer menu) of your wiki and then find the Import menu.
22 ** Alternatively you can point your browser to ##http:~/~/localhost:8080/xwiki/bin/admin/XWiki/XWikiPreferences##
23 * Attach the XAR file you wish to import and then **select it from the list** under "Available packages". After a few seconds you should see the list of all the pages in your XAR listed and selected by default (unselect the pages/folders you don't wish to import):(((
24 {{image reference="importpage.png"/}}
25 )))
26 * Select the second radio button if you want to replace the document history with the history from the imported package. If you don't select it the newly imported pages will have the revision "1.1"
27 * In case you want to preserve the author for the imported pages, check the "Import as backup package" option.
28 * Click "Import". This will import all the selected pages
29 * At this stage your rights might have been changed as the import may have imported different rights. You may need to log out and log in again.
30
31 {{info}}
32 If you own the sub-wiki (virtual wiki, wiki-farm), you need to be sure that you either:
33 * install with a global user having Programming Rights (PR) and UNCHECK the backup pack option
34 * install with a global user having PR and keep the backup pack option but in this case MAKE SURE that the user defined in the XAR exists and has PR.
35 Otherwise all imported pages would be saved without PR and scripts won't work until you resave them under the user with Programming Rights .
36
37 Note, that pages requiring PR are supposed to also contain a XWiki.RequiredRightClass xobject so it should be easy to query them. If you find some that don't have this XObject please let us know. This XObject is just indicative and doesn't change permissions.
38 {{/info}}
39
40 {{warning}}
41 If you get a 'Java heap space Out Of Memory exception' you'll need to increase the memory allocated to the JVM running XWiki. How you do this depends on the container you use:
42 * For Jetty you must change a line in ##start_xwiki.bat## (or ##start_xwiki.sh##) from //JAVA_OPTS=-Xmx300m// to something like //JAVA_OPTS=-Xmx1024m//
43 * For Tomcat you must set //CATALINA_OPTS// to something like //-Xmx1024m//
44 {{/warning}}
45
46 == Importing an Extension ==
47
48 When you import a XAR, if the XAR's ##package.xml## contains an ##extensionId## value (representing an Extension Id) then the Importer will check if the Extension exists in its configured XWiki Extension Repositories (the configuration for this is located in ##xwiki.properties## under the ##extension.repositories## keys). If the Extension is found, the Importer will then register it in the list of installed Extensions that you can see when going to the [[Extension Manager Application's UI>>extensions:Extension.Extension Manager Application]].
49
50 = Exporting XWiki pages =
51
52 Prerequisites:
53
54 * A configured database and Servlet Container. If you don't have them, see the [[Installation guide>>Documentation.AdminGuide.Installation]].
55
56 Follow these steps:
57
58 * Ensure your database and container are started
59 * Point your browser to ##http:~/~/localhost:8080/xwiki/bin/admin/XWiki/XWikiPreferences##
60 * Click "Export" and fill the form
61 * Click "Export"(((
62 {{image reference="ExportPackageFlamingo.png"/}}
63 )))
64
65 == Customizing a XAR ==
66
67 When doing an export, XWiki pages are saved using the [[XAR format>>Documentation.AdminGuide.ImportExport||anchor="HXARFormat"]]. A typical XAR created when doing an export will include all the pages on your XWiki instance. However you can [[control this using a custom Export URL>>platform:Features.Exports||anchor="HXARExport"]].
68
69 That said, it is also possible to create a XAR that will include only the pages you want. This is useful when you want to export only the pages of a specific application for example. Here are the steps:
70
71 * Unzip the file
72 * Keep the pages you want to put in your archive
73 * Edit ##package.xml## to delete the pages you do not want to be in the archive
74 * Zip together the modified ##package.xml## file and the pages you want to put together in your archive, naming the file "MyArchive".xar where "MyArchive" is the actual name you want to give it
75 * You're done! You can now import this specific set of pages to any XWiki instance
76
77 {{info}}
78 In the future XWiki will offer the ability to do selective exports natively. For the moment you'll need to install the [[Multipage Export Extension>>extensions:Extension.Multipage Export Application]].
79 {{/info}}
80
81 = XAR Format =
82
83 See [[XAR Format specifications>>extensions:Extension.XAR Module Specifications]].

Get Connected