October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Back Up and Restore Nextcloud on a VPS

A complete Nextcloud VPS backup combines configuration, data, theme, custom apps, and the database. This guide shows how to create a consistent copy, restore each database type, protect credentials, and run the data fingerprint command so sync clients recover cleanly.
Length9 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A reliable Nextcloud VPS backup is a coordinated copy of five things: the configuration, the data directory, the database, the theme, and any custom apps. Put the instance in maintenance mode before copying, keep at least one copy outside the VPS or Nextcloud environment, and restore the files and database as one set. After recovery, run maintenance:data-fingerprint so desktop and mobile clients recognize the restored state instead of treating it as an unexplained change.

What a complete Nextcloud backup must contain

Nextcloud stores an installation across the filesystem and a database. A copy of only one side is not a usable disaster-recovery backup. The current Nextcloud administration guidance identifies these items to retain:

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Configuration directory: this includes config.php, which contains database connection credentials and other instance settings.
  • Data directory: users’ files and related data live here. It may be outside the web root, depending on how the VPS was configured.
  • Database: MariaDB, MySQL, SQLite, or PostgreSQL records users, shares, file metadata, settings, and other application state.
  • Theme directory: retain it when the installation uses a custom theme.
  • Custom apps directory: include it when custom apps are installed. Those apps may provide database tables or files that the restored instance expects.

Keep the directory copy and the database dump from the same backup run. Restoring a newer database against an older data directory, or the reverse, can leave metadata and files out of sync.

Prepare the VPS before copying anything

Choose a destination outside the Nextcloud environment

Write the backup to storage that is not the live Nextcloud directory. A second disk, a mounted backup volume, or an off-server repository can protect the copy when the VPS itself is lost or corrupted. At least one copy should be outside both the VPS and the Nextcloud environment. Apply restrictive permissions to the directory and database dump: the files may contain private user content, while config.php contains database credentials.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

Keep enough space for both the directory copy and the SQL dump. Do not place the destination inside the source tree, because a recursive copy can then include its own output or consume the filesystem needed by the running service.

Record the account and paths you will use

The examples below use www-data as the HTTP user and assume the shell is run from the directory containing nextcloud/. Use the actual web-server account and paths for your VPS. Database host, user, password, and database name must match the installation’s configuration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Step-by-step: create a consistent backup

1. Enable maintenance mode

Run the command as the HTTP user with the environment preserved:

sudo -E -u www-data php occ maintenance:mode --on

Maintenance mode locks the sessions of logged-in users and prevents new logins. This stops active requests from changing files while you are making the copy. Confirm that the web interface shows maintenance mode before proceeding; do not start the file copy while users can still write.

2. Copy the Nextcloud directories

The manual’s documented pattern uses rsync and a date-stamped destination:

rsync -Aavx nextcloud/ nextcloud-dirbkp_`date +"%Y%m%d"`/

The archive and verbose flags preserve ownership-related attributes and show progress, while -x keeps the operation on the same filesystem. The resulting directory copy should contain the configuration, data, theme, and custom apps required by your installation. If your data directory is stored outside nextcloud/, copy that path into the same backup set rather than assuming the example command reaches it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed

Do not omit a custom apps directory simply because the core files were copied. Likewise, retain a custom theme directory when one is present. A plain core-code copy without these additions may boot but fail when users open files, log in, or load a customized interface.

3. Dump the database while maintenance mode remains on

Choose exactly the client that matches the database engine. The commands below write a dated dump beside the directory backup:

Database engine Backup command
MariaDB
mariadb-dump --single-transaction -h [server] -u [username] -p[password] [db_name] > nextcloud-sqlbkp_`date +"%Y%m%d"`.bak
MySQL
mysqldump --single-transaction -h [server] -u [username] -p[password] [db_name] > nextcloud-sqlbkp_`date +"%Y%m%d"`.bak
SQLite
sqlite3 data/owncloud.db .dump > nextcloud-sqlbkp_`date +"%Y%m%d"`.bak
PostgreSQL
PGPASSWORD="password" pg_dump [db_name] -h [server] -U [username] -f nextcloud-sqlbkp_`date +"%Y%m%d"`.bak

For MariaDB or MySQL installations configured for four-byte character support, add --default-character-set=utf8mb4 to the corresponding dump command. Keep passwords out of shell history where your operational practice allows; the examples mirror the documented syntax, but the resulting dump and any shell logs must be protected like the live database.

4. Check the backup before reopening the service

Confirm that the dated directory exists, that it contains the expected configuration, data, theme, and custom-app content, and that the dump file has a nonzero size. A successful command exit alone does not prove that the intended destination was used. Preserve the directory copy and dump together, and transfer at least one complete set off the VPS. If you encrypt backups, preserve the decryption key separately from the encrypted data and document who can retrieve it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

5. Turn maintenance mode off

After the copy and basic checks complete, return the service to normal operation:

sudo -u www-data php occ maintenance:mode --off

If the backup itself exposed an error, leave maintenance mode enabled while you correct the backup rather than allowing users to change the instance without a known recovery point.

Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

Restore a Nextcloud VPS from a directory copy and database dump

1. Stop writes and prepare the target

On the target VPS, enable maintenance mode before replacing files. The target may be the original host after a failure or a rebuilt VPS. Place the saved directory copy and database dump where the account performing the restore can read them, with permissions that do not expose user data or credentials.

Restore the configuration, data, theme, and custom-app directories as one set. A documented file-restore pattern is:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
rsync -Aax nextcloud-dirbkp/ nextcloud/

Keep the source trailing slash and verify that the destination is the intended Nextcloud installation. If the data directory was stored separately, restore it to the same path recorded in the configuration. Do not mix directories from different backup dates.

2. Re-create the database before importing

Before loading a dump into MariaDB, MySQL, or PostgreSQL, remove the existing tables. The restore guidance recommends dropping and recreating the database so old tables cannot conflict with the saved schema. Perform that operation only against the database named in the restored configuration; selecting the wrong database is destructive.

For SQLite, remove the existing database file and create it again from the dump. The SQLite example in the manual uses data/owncloud.db.

3. Import with the matching database client

Database engine Restore command
MariaDB
mariadb -h [server] -u [username] -p[password] [db_name] < nextcloud-sqlbkp.bak
MySQL
mysql -h [server] -u [username] -p[password] [db_name] < nextcloud-sqlbkp.bak
SQLite
rm data/owncloud.db
sqlite3 data/owncloud.db < nextcloud-sqlbkp.bak
PostgreSQL
PGPASSWORD="password" psql -h [server] -U [username] -d nextcloud -f nextcloud-sqlbkp.bak

Use the same engine and database identity represented in the restored configuration. A MariaDB dump is not imported with the PostgreSQL client, and a SQLite file is not restored by redirecting it into a server database.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

4. Reconcile sync clients with the restored state

Once the files and database are back in place, run:

sudo -u www-data php occ maintenance:data-fingerprint

This changes the ETag communicated to sync clients. The clients can then recognize that files were modified by a restore and reconcile their local state instead of assuming that the server still has the pre-failure version. Run this after restoring either the data directory or the database, not before.

5. Test the instance while it is still offline to users

Use the web interface and a test account to check:

  • login and logout;
  • a representative file download, upload, rename, and deletion;
  • existing shares and shared-folder permissions;
  • calendars and contacts;
  • background jobs;
  • custom apps and theme behavior;
  • external storage integrations.

Watch the application and web-server logs while performing these checks. If a database connection, file path, app, or external storage integration fails, keep maintenance mode on and correct it before exposing the restored instance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

6. Reopen the service

When the checks pass, disable maintenance mode:

sudo -u www-data php occ maintenance:mode --off

Ask a real sync client to connect and verify that it receives the restored state cleanly. A restore is not complete merely because the login page loads; the database, files, clients, and integrations must agree.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common failure modes and how to avoid them

Copying while users are active

Active sessions can write database rows or file content during the copy, producing a directory and database that describe different moments. Enable maintenance mode first. Its purpose is specifically to lock existing sessions and prevent new logins during the operation.

Saving only files or only SQL

A filesystem-only backup lacks database metadata, shares, and application state. A database-only backup lacks the actual user files and configuration needed to serve them. Keep both artifacts from one maintenance window and restore them together.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

Forgetting custom apps or the theme

Core files do not recreate locally installed apps or a custom theme. Include those directories in the backup set whenever they exist, then test them before leaving maintenance mode.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leaving credentials and personal data unprotected

The configuration contains database credentials, and the data directory can contain every user’s private content. Restrict filesystem access to the backup directory and dumps, and treat off-server copies as sensitive records. If encryption is used, key custody is part of the backup design: an encrypted archive without its key cannot be restored.

Skipping the data fingerprint

After a restore, sync clients may still hold assumptions about the old server state. Running maintenance:data-fingerprint updates the ETag they receive and gives them the signal needed to recognize the restored files.

Importing into a database that still has old tables

Old tables can conflict with the dump or leave records that were not present at backup time. Drop and recreate the target database as recommended, then import the matching dump. Double-check the database name before issuing a destructive command.

Using the optional Nextcloud Backup app

The official nextcloud/backup project documents encrypted backup points and the occ backup:point:restore workflow. It can be an additional workflow, but it does not remove the need to understand what is being protected and how it will be recovered.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The app’s setup export contains encryption keys. Preserve that exported setup and its encryption key with the backup records. Losing either can prevent decryption of encrypted backup points. Verify the behavior of the app version installed on your VPS before making it the sole disaster-recovery method; a manual directory-and-database set remains a clear, portable fallback.

Choose a backup design you can actually recover

When comparing manual exports, coordinated VPS snapshots, and an application-based workflow, evaluate the same practical dimensions:

  • Consistency control: maintenance mode or another coordinated snapshot method must prevent files and database state from diverging.
  • Scope: confirm that the approach captures configuration, data, theme, custom apps, and database rather than a partial directory.
  • Restore portability: determine whether the backup can be restored only to the same host or also to a rebuilt VPS.
  • Off-site durability: keep at least one complete copy outside the Nextcloud environment and VPS.
  • Encryption and key custody: document encryption keys and who can retrieve them.
  • Retention and deletion recovery: retain more than the newest copy when recovering from an unnoticed deletion or corruption matters.
  • Restore evidence: perform a test restore and record whether login, files, sharing, calendars, contacts, jobs, sync clients, and external storage all work.

No universal backup frequency, restore-time target, or storage-capacity figure is established here. Set those values from the amount and change rate of your own data, the acceptable loss window, available storage, and the time your team can spend validating a restore. The meaningful test is a completed recovery, not the existence of an archive file.

A compact recovery checklist

  1. Enable maintenance mode on the source or target instance.
  2. Copy configuration, data, theme, and custom-app directories.
  3. Dump the database with the client for MariaDB, MySQL, SQLite, or PostgreSQL.
  4. Protect the copy and move one complete set off the VPS.
  5. On restore, copy all directories back together.
  6. Drop and recreate the server database, or replace the SQLite file, then import the matching dump.
  7. Run sudo -u www-data php occ maintenance:data-fingerprint.
  8. Test login, files, shares, calendars, contacts, jobs, apps, theme, and external storage.
  9. Disable maintenance mode only after those checks succeed.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.