Nextcloud Storage Planning: VPS Disk or External Storage?

Published on

Plan Nextcloud disk space on a VPS: what versions, trash and previews use, how to cap them, VPS disk vs external or S3 storage, data moves and backups.

A VPS panel with a disk usage bar at 0.96 of 120 GB and a bandwidth meter at 0 of 30000 GB

Your Nextcloud disk fills faster than your uploads explain, or you are about to move years of photos into a new install and need to size the VPS disk. Nextcloud keeps old versions, deleted files and previews next to your files, and where the data directory lives decides what you can change later. The install itself is in our Nextcloud setup guide and self-hosting guide.

Quick answer: Old versions, deleted files and previews all take disk space, and none of them count against user quotas. With a quota, versions and the trash may each use up to half of the user's remaining quota, so together with the files they stay within about the quota. Without a quota, Nextcloud measures against the free disk space, so both can keep growing until the disk is full. Set quotas or cap retention, then size the disk as the sum of all quotas plus about 10% for previews and other metadata. Keep the data directory on the VPS disk while it fits, mount archives with the External storage app, and use S3 as primary storage only on a new install.

Where the Space Goes

Each user gets a folder in the data directory (datadirectory in config.php, /var/www/nextcloud/data in Nextcloud's examples):

WhatPath in the data directoryCounts toward the quotaHow large it can grow
Files<user>/filesYesWhat users upload, up to the quota
Old versions<user>/files_versionsNoHalf the remaining quota; without a quota, the free disk space
Deleted files<user>/files_trashbinNoHalf the remaining quota; without a quota, the free disk space
Previewsappdata_<instanceid>/previewNoPart of the metadata Nextcloud puts at about 10% of disk space

A few rules decide the real numbers:

  • Each version is a full copy of the file. The default pattern keeps one per hour for the first day, one per day for 30 days, then one per week with no end date, so a 2 GB video changed on ten different days can keep 20 GB of old versions.
  • Deleted files have no end date by default. The auto policy removes them when space is needed, not after 30 days. Versions of a deleted file go to the trash with it, and a file deleted from someone else's share lands in the owner's trash and usually in the deleter's too.
  • Previews start big. For each image, Nextcloud first renders one preview of up to 4096 by 4096 pixels by default, then makes the smaller sizes from it.
  • Uploads need temporary space of at least the maximum upload size times the number of people uploading at once, per Nextcloud's big file guide.

Measure What You Use Now

Run occ from the Nextcloud folder as the web server user, www-data on Ubuntu 24.04 and Debian 12. The examples use /var/www/nextcloud and a user called alice; replace the data path with the one the second line prints:

cd /var/www/nextcloud
sudo -E -u www-data php occ config:system:get datadirectory
df -h /var/www/nextcloud/data
sudo du -h --max-depth=2 /var/www/nextcloud/data | sort -h
sudo -E -u www-data php occ user:info alice
sudo -E -u www-data php occ info:file:space /alice/files

df shows the free space on the data partition. The du line lists each user's files, files_versions and files_trashbin and the appdata_*/preview folder, largest last. user:info shows the quota and the space Nextcloud counts as used; info:file:space ranks the largest items in a folder.

On Docker, start occ with sudo docker exec -it --user www-data <container> php occ (official image) or sudo docker exec --user www-data -it nextcloud-aio-nextcloud php occ (All-in-One), whose data sits in /var/lib/docker/volumes/nextcloud_aio_nextcloud_data/_data/ by default.

Put a Ceiling on Versions and Deleted Files

The simplest ceiling is a quota: on the Users page, the gear icon at the bottom left sets a default for new users, and each user has a Quota dropdown. With a quota, Nextcloud trims old versions and deleted files once either passes half of what is left of it. Size the disk as the sum of all quotas plus about 10%, with room for the system, database and temporary uploads.

Without quotas, or as a second guard, set retention limits in config.php and, if you want one, a fixed trash size:

sudo -E -u www-data php occ config:system:set trashbin_retention_obligation --value="auto, 30"
sudo -E -u www-data php occ config:system:set versions_retention_obligation --value="auto, 180"
sudo -E -u www-data php occ trashbin:size 5GB

auto, 30 deletes trash older than 30 days, and newer items when space is needed. auto, 180 deletes versions older than 180 days and thins the rest by the usual pattern; versions a user has named are never deleted. trashbin:size gives every user's trash a fixed target in place of the quota rule (--user alice sets one user's), and changing the global value starts a cleanup at once. Background jobs apply these rules every 30 minutes; occ trashbin:expire and occ versions:expire apply them now.

To free space immediately, occ trashbin:cleanup alice empties alice's trash and occ versions:cleanup alice deletes her versions. trashbin:cleanup --all-users, or versions:cleanup without a name, does it for everyone, with no undo.

Previews. Lower the maximum size and clear the old previews, which Nextcloud regenerates as people open files:

sudo -E -u www-data php occ config:system:set preview_max_x --value=2048 --type=integer
sudo -E -u www-data php occ config:system:set preview_max_y --value=2048 --type=integer
sudo -E -u www-data php occ preview:cleanup

Previews for video, PDF and Office files are off by default, and Nextcloud discourages turning them on.

VPS Disk, External Storage or Object Storage

Nextcloud can keep files in three places:

Data directory on the VPS diskExternal storage appS3 as primary storage
When you can set it upAt install (the default)Any time, per folderBefore the first start
Files seen from outsideNormal filesNormal files on the remote sideObjects named by ID; names and folders exist only in the database
What still uses the VPS diskEverythingOld versions, deleted files and previewsTemporary upload space and some files in the data directory
What to back upData directory and databaseThe remote storage, separatelyBucket and database, as a pair

The VPS disk is the default and simplest layout: one place for everything, with quotas as described. The limit is the disk. On our VPS plans that is 60 to 300 GB of NVMe on Standard and 20 to 240 GB on Premium, and the order form offers extra NVMe storage as an add-on. On a new install, Nextcloud's hardening guide recommends a data directory outside /var/www.

The External storage app ships disabled; enable it under Apps and add mounts in the Administration settings under External storage. It connects Amazon S3, FTP/FTPS, Local folders such as a second disk, another Nextcloud, OpenStack Object Storage, SFTP, SMB/CIFS and WebDAV, and the files stay normal files on that side. Four catches:

  • External files don't count toward quotas unless you set quota_include_external_storage to true, which the docs call experimental.
  • Changes made outside Nextcloud stay invisible until a scan, so run occ files_external:scan <mount_id> from cron (occ files_external:list shows the ID). A rename made outside Nextcloud counts as a delete plus a new file, which loses its shares, tags and comments.
  • Old versions of external files, and files deleted from a mount, are kept in the user's folders in the data directory, so editing or deleting large files there uses VPS disk space. Previews of external files are stored there too; each mount's settings can switch them off.
  • All-in-One's built-in backup skips external storage.

S3 as primary storage, set with an objectstore block in config.php, puts every file in the bucket while only the database knows names and folders. It reaches past any single disk and, per the docs, usually performs better than the same bucket through the External storage app. The costs: Nextcloud needs the bucket to itself, your files are unreadable without the database, and configuring it on an existing instance makes all existing files inaccessible. Uploads still need local temp space unless memcache.distributed uses Redis or Memcached, which lets Nextcloud stream chunks to S3 as a multipart upload.

Which One Fits

  • Your files fit on the VPS disk with room to grow: keep the data directory there, set quotas and cap trash and versions.
  • A large archive that rarely changes or that other tools write to: keep the live files on the VPS disk and mount the archive with the External storage app, previews off.
  • A new install that will outgrow one disk: use S3 as primary storage from the first start, with Redis, and back up bucket and database together.
  • An existing install running out of space: clean up versions and trash, then add disk space; if it comes as a second disk, move the data directory as below. Don't add primary object storage to it.

Moving the Data Directory to a Bigger Disk

Nextcloud identifies local storage by its absolute path, and its docs call changing datadirectory unsupported: done carelessly, Nextcloud treats the content as new storage, with duplicate or orphaned files and lost share links. The documented method keeps the path by moving the data and leaving a symlink. With a second, empty disk (lsblk -f lists it; here /dev/vdb), adjusting the paths to yours:

sudo apt install rsync            # if it is not installed yet
cd /var/www/nextcloud
sudo -E -u www-data php occ maintenance:mode --on    # then wait 6 to 7 minutes
sudo crontab -u www-data -e        # put a # before the cron.php line
sudo systemctl stop apache2        # or nginx and your php-fpm service
sudo mkfs.ext4 /dev/vdb            # erases /dev/vdb
sudo mkdir /mnt/ncdata
echo "UUID=$(sudo blkid -s UUID -o value /dev/vdb) /mnt/ncdata ext4 defaults 0 2" | sudo tee -a /etc/fstab
sudo mount -a
sudo rsync -Aavx /var/www/nextcloud/data/ /mnt/ncdata/data/
sudo mv /var/www/nextcloud/data /var/www/nextcloud/data.old
sudo ln -s /mnt/ncdata/data /var/www/nextcloud/data
sudo systemctl start apache2
sudo -E -u www-data php occ maintenance:mode --off

Nextcloud's migration guide adds the wait so sync clients notice maintenance mode. The trailing slash copies the folder's contents, the hidden .ncdata file included, and -a keeps owners, permissions and timestamps; new timestamps would make clients download everything again. Check permissions, parent folders included; your web server may need to allow symlinks. Then remove the # from the crontab, open a few files, and delete data.old once you are sure.

With Docker, Nextcloud sees the path inside the container (/var/www/html/data in the official image), so move the host side of the volume or bind mount and keep that path. All-in-One's README says not to change NEXTCLOUD_DATADIR after the first installation, so choose it before the first start.

Back Up Files, Config and Database Together

Nextcloud's backup guide lists the config, data and theme folders, the database, and the custom apps folder if you installed apps there. Use maintenance mode while you copy so files and database match, dump the database with mariadb-dump or pg_dump, and send the copy off the server, for example with restic over SSH. A copy on the same disk shares its fate and doubles the space you need.

  • VPS disk: the data directory and a database dump. After a symlink move, back up the real path (/mnt/ncdata/data), because rsync -a copies a symlink as a link, not the files behind it.
  • External storage: back up the remote side on its own.
  • S3 primary storage: the docs say your backup strategy has to cover the bucket. The files are useless without the database, so back up both at the same moment and restore them as a pair.

Backups need space too: our backup storage guide shows how retention multiplies it, and a restore drill proves the copy works. Backups are not included in the plan price of a Space-Node VPS, but you can arrange them through a support ticket.

FAQ

Do old versions and deleted files count against a user's quota? No. They get their own limits instead: with a quota, each may use up to half of the user's remaining quota; without one, the free space on the data partition sets the limit.

Can I switch an existing Nextcloud to S3 primary storage later? Not by adding the objectstore block: the docs warn that this makes all existing files inaccessible. Decide before the first start, or mount the bucket with the External storage app instead.

Does server-side encryption need much more disk? About 1% more since Nextcloud 25, according to the encryption docs; before that it was 35%. Quotas count the unencrypted size.

Why does Nextcloud show less used space than du? The used space covers only the files in <user>/files; metadata, versions, the trash and encryption keys are left out. If the files figure itself looks wrong, occ files:scan -vvv alice can fix the sizes.

Sources

All opened on 31 October 2026: