Okay, here's a comprehensive guide on how to download your Wiki.js data from your DigitalOcean droplet and redeploy it on your own server:
I. Backing up your Wiki.js Data from DigitalOcean
Since the file list doesn't contain a dedicated backup/restore guide, we'll use a general approach to backing up the relevant data:
-
Access your DigitalOcean Droplet: Use SSH to connect to your DigitalOcean droplet as the root user or a user with sudo privileges.
ssh root@your_droplet_ip_address
-
Identify the Database Type: Wiki.js supports various databases (PostgreSQL, MySQL, MariaDB, MS SQL Server, SQLite). You need to know which one you're using. The configuration file (config.yml) holds this information. The location of config.yml should be in the root Wiki.js directory, or within the _dist/wiki directory after the build.
-
Locate the dataPath: The dataPath in your config.yml file specifies where Wiki.js stores files like images and temporary uploads. You'll need to back this up as well. By default, this is ./data.
-
Back up the Database: The method for backing up the database depends on the type of database you are using:
-
PostgreSQL:
# Become the postgres user
sudo -i -u postgres
# Dump the database to a file
pg_dump wiki > wiki_db_backup.sql
# Exit the postgres user
exit
-
MySQL/MariaDB:
mysqldump -u wikijs -p'wikijsrocks' wiki > wiki_db_backup.sql
(Replace wikijs, wikijsrocks, and wiki with your actual MySQL/MariaDB username, password, and database name, respectively.)
-
SQLite: If you're using SQLite, the database is a single file. Simply locate the file specified by the storage option in your config.yml and copy it. By default, the database is stored in path/to/database.sqlite.
-
Back up the dataPath directory:
tar -czvf wiki_data_backup.tar.gz ./data
(Replace ./data with the actual path to your dataPath directory if it's different.)
-
Download the Backup Files: Use scp or rsync to download the wiki_db_backup.sql (or the SQLite database file) and wiki_data_backup.tar.gz files to your local machine.
scp root@your_droplet_ip_address:wiki_db_backup.sql .
scp root@your_droplet_ip_address:wiki_data_backup.tar.gz .
II. Deploying Wiki.js on Your Own Server
-
Server Requirements: Refer to the Requirements documentation for Wiki.js. You'll need a server running NodeJS.
-
Install NodeJS: Install NodeJS.
-
Install Database: Install the database you were previously using (PostgreSQL, MySQL/MariaDB, or SQLite).
-
Install Wiki.js:
- Download the latest Wiki.js release from the Official Website or Releases.
- Extract the downloaded archive to a directory on your server.
- Navigate to the extracted directory in your terminal.
- Install dependencies:
yarn install --production or npm install --production
-
Configure Wiki.js:
- Copy
config.sample.yml to config.yml: cp config.sample.yml config.yml
- Edit
config.yml to match your new server's configuration, especially the database settings.
-
Restore the Database:
-
PostgreSQL:
# Become the postgres user
sudo -i -u postgres
# Create the database
createdb wiki
# Restore the database from the backup file
psql wiki < wiki_db_backup.sql
# Exit the postgres user
exit
-
MySQL/MariaDB:
mysql -u wikijs -p'wikijsrocks' wiki < wiki_db_backup.sql
(Replace wikijs, wikijsrocks, and wiki with your actual MySQL/MariaDB username, password, and database name, respectively.)
-
SQLite: If you're using SQLite, simply replace the newly created SQLite database file (created during Wiki.js installation) with the backup you downloaded from your DigitalOcean droplet. The database file location is specified in your config.yml
-
Restore the dataPath: Extract the wiki_data_backup.tar.gz archive into the location you've specified as in your .
Important Considerations:
- File Permissions: After restoring the
dataPath, ensure that the files and directories have the correct ownership and permissions so that the Wiki.js process can access them.
- Firewall: Make sure your server's firewall allows traffic on the port Wiki.js is using (default 3000).
- Reverse Proxy (Recommended): For production deployments, it's highly recommended to use a reverse proxy like Nginx or Apache in front of Wiki.js. This allows you to use SSL/TLS for secure connections, serve Wiki.js on standard ports (80/443), and handle other web server tasks.
- SSL/TLS: Configure SSL/TLS for your Wiki.js instance to encrypt traffic. Let's Encrypt is a free and easy way to obtain SSL certificates.
- Configuration: Review all settings in your
config.yml file after restoring to ensure they are correct for your new server environment. Pay close attention to the ssl settings, especially if you were using Let's Encrypt on your DigitalOcean droplet. You might need to reconfigure these settings.
- Email: If you're using email functionality, ensure that your email settings in Wiki.js are configured correctly for your new server.
- Search Index: If you're using a search index (like Solr), you might need to rebuild the index after restoring the database and data files.
- Docker: Consider using docker to deploy Wiki.js. You can use the
dev/examples/docker-compose.yml file to set up Wiki.js deployment on your own server.
- Helm: If you are using Kubernetes, you can use the Helm chart in the repository to deploy Wiki.js.
This detailed guide should help you migrate your Wiki.js data and redeploy it successfully. Remember to adapt the commands and paths to match your specific server configuration.