r/webdev • u/TheRedditerater • 15d ago
Tool, or technique, to compare local and server versions of a massive static site?
I have a large static Web site (essentially a photo galerie) that registers locally as 169.364 Files / 49.3 Gb on Windows explorer and 168,212 files / 21 Gb on the server cPanel file manager. Most of the weight comes from 300-400 Kb jpg photographs (so, files already compressed locally).
What would be the best tool or method to detect where this disk space discrepancy come from, short of checking sequentially each of the 4,402 directories?
EDIT:
rclone finally snagged the culprit: a directory full of TIF files coming from the high res. scans of my grandma's B&W and colour photographs. I had them temporary uploaded on the server years ago for my people to download and archive them. I then deleted the server side copies but completely forgot to remove them from my local image...
Thanks to all who chimed in! I am still learning rclone because it detected a bunch of other anomalies in there, but the main discrepancy in size is now solved. Awesome.
8
u/One_Public9519 15d ago
300-400 Mb per jpg? 169k files at that size would be petabytes, you mean Kb. And cPanel reports block usage per inode while Explorer reports apparent size, they will never agree, so check du -sh on the server and TreeSize or WizTree on the local drive before you go chasing anything. For the actual diff rsync -n -i --delete with the same base path on both sides prints every file that differs in one pass, you don't need to open 4400 directories.
4
u/cuelark 15d ago
Instead of walking the directories by hand, I would compare file lists with sizes and let a tool do the diff. If you have SSH on the host, rsync in dry-run mode is great for this: rsync -avn --itemize-changes from your local folder to the server (WSL or Git Bash works on Windows). It prints every file that is missing or differs in size, without copying anything. If you only have FTP, FreeFileSync or WinSCP's synchronize view can do the same comparison by size and date.
A few things that could explain the gap: the 1,152 missing files may be your biggest ones (sort the diff by size), Explorer's "size" and cPanel's disk usage are measured differently, and some local folders may hold original exports or Thumbs.db files that never got uploaded. Once you have the list, sort it by size and the 28 GB difference will probably show up in a handful of folders.
3
u/snap-dev 15d ago
with only ~1,150 fewer files but more than double the size locally, i'd bet on duplicates, originals or cache folders sitting on your machine rather than missing uploads.
my devs do this whenever local and server drift apart: dump a file list with sizes on both sides and diff them. something like find . -type f -printf '%P\t%s\n' | sort > local.txt locally (on a mac use gfind from findutils), same thing on the server via ssh or cPanel's terminal, then diff or throw both into a spreadsheet and sort by size. the big culprits jump out fast. also look for hidden junk like .DS_Store, Thumbs.db or a lightroom preview folder, those pad the count.
3
u/Ok-Snow-6553 15d ago
The easiest way to find this without clicking through folders is using a disk usage analyzer.
ncdu(NCurses Disk Usage). It shows you a visual, interactive tree of exactly what's taking up space.Most likely, the transfer was interrupted and hundreds of images didn't upload (hence the missing file count). I'd suggest re-uploading via SFTP using FileZilla or WinSCP, which is much more reliable for 21GB+ of data than the cPanel web uploader.
3
u/ZealousidealUse8775 15d ago
du -sh on the server and you're done in a minute, nobody checks 4402 directories by hand.
400Mb jpgs on a photo gallery is the actual problem here.
2
u/tremby 15d ago
Have shell access? If so, rsync is good for that. You can run it in dry run mode and have it itemize all differences.
If no shell access, I'd grab everything down to a local copy via whatever means (FTP? wget recursive?) and then look at the differences with diff or rsync.
2
u/Needle_In_Red 15d ago
id run rclone check (or winscp's compare directories) against the server, itll spit out exactly which files are missing or differ instead of eyeballing 4k folders
2
u/Classic-Chipmunk1098 15d ago
Small thing, but 300-400 Mb per jpg means a third of a gigabyte per photo, so your 49 Gb would be roughly 130 pictures total. You mean Kb, presumably.
2
u/StatsDota_Dmitrii 15d ago
first thing i would check is Thumbs.db and desktop.ini, windows likes to drop them in every photo folder and they usually never get uploaded. with 4400 folders thats easily your ~1150 extra files. for the size gap id just dump file list with sizes on both sides (find -type f), sort and diff, explorer and cpanel never agree on anything anyway
2
u/Weekly-Offer-4172 15d ago
if the host is cpanel only with no ssh you dont need to download the content, just the listings. rclone speaks ftp so rclone lsf -R --format pst against both sides gives you two name and size lists you can diff in minutes, or rclone check --size-only localdir remote:ftp prints the mismatches directly. worth treating the count gap (1,152 files) and the size gap as possibly different problems too, gallery and cms plugins often generate resized variants on the server that never existed locally. and check whether cpanel's file manager is counting hidden files like .htaccess and index placeholders that explorer hides by default
1
u/adilbasari 15d ago
The math lets you skip almost all of this: only about 1,150 files differ in count, but 28 GB differs in size. That means a handful of very large files are responsible, not general drift. So diff by size, not by presence. Export both listings with sizes (locally a find that prints size and path, on the server via SSH or cPanel's disk usage export), sort by absolute size difference, and look at the top ten rows. The 28 GB will be sitting in a few obvious paths within a minute of sorting.
Two usual suspects when counts nearly match but sizes don't: partially failed uploads that left truncated files on the server, look for identical names with different sizes, and the apparent versus allocated size reporting difference already mentioned upthread, though for large files that effect is small.
2
u/Open-Adhesiveness-86 15d ago
If you go the rsync dry-run route, add --size-only. By default it compares size plus mtime, and most FTP/SFTP uploads don't preserve timestamps, so you'll get 168k bogus "differs" lines and learn nothing. Also keep --delete out of it entirely, one forgotten -n and you've nuked the server side.
1
u/Eugene_Kosten 15d ago
hosting companies almost always count actual block usage on the server filesystem rather than the apparent size shown in windows explorer, and with 168k files you also want to check your plan's inode limit since many shared cpanel hosts cap total file counts around 250k.