r/webdev • • 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.

13 Upvotes

36 comments sorted by

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.

1

u/TheRedditerater 15d ago

Good catch, thx! Yes, it's Kb. OP edited.
Do web hosting companies typically publish a server space limit for their plans as a cumulative "block usage per inode" on their server or what the customer sees on their local Unix or Window machine?

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.

1

u/TheRedditerater 15d ago

Got it, thx! I have to learn using this SSH command syntax. Shouldn't the initial command includes a -i to display the results?

1

u/cuelark 14d ago

yep, --itemize-changes is the long form of -i, so it is already in that command. -n is what makes it a dry run and prints the planned changes without copying.

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.

1

u/TheRedditerater 15d ago

Great, thx for these additional pointers.
Not sure what is "my devs" though. Is'nt it for a dev team protected access? sorry, total ssh noob here.

3

u/Ok-Snow-6553 15d ago

The easiest way to find this without clicking through folders is using a disk usage analyzer.

  1. If you have SSH access to the server, run ncdu (NCurses Disk Usage). It shows you a visual, interactive tree of exactly what's taking up space.
  2. If you don't have SSH, look for a "Disk Usage" feature in your cPanel.

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.

1

u/TheRedditerater 15d ago

Thanks.

  1. → Then I would have to compare the ncdu tree to something similar on my local version, right? Would windows explorer be suitable for that? I am using Space Monger locally to track monsters visually.
  2. → I thought of doing that, but it takes a while and won't let me identify what files were the culprit if I achieve equal size both side when finished.

1

u/Ok-Snow-6553 15d ago

Your approach makes sense.

  1. Yes, comparing the ncdu tree with Space Monger locally is perfect. Look for the biggest folders that differ in size.
  2. To find the exact missing files without re-uploading everything, try WinMerge (free folder compare tool) or use rsync with the --dry-run flag via WSL. It will just show you a list of files that are missing on the server, without actually transferring anything.

Since you have 4000+ folders, this is way faster than checking manually.

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.

1

u/TheRedditerater 15d ago

Yes, I'll do ssh server side when I get familiar with the syntax. And the Mb should have read Kb, my bad. OP edited.

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.

1

u/TheRedditerater 15d ago

I have shell access but I not an expert and have rarely used it. Thanks for the pointers. An opportunity to learn.

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

1

u/TheRedditerater 15d ago

and another tool! Awesome. I gather that this one has no risk to synch anything if I mess up the command. So may be better suited for me.

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.

1

u/TheRedditerater 15d ago

Correct, thx. Was suggested in an earlier comment. I edited my OP.

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

1

u/TheRedditerater 15d ago

Ah... I'd love to speak SSH fluently! Guess this is the opportunity to learn a bit.

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

2

u/TheRedditerater 15d ago

Ok, thx, I'll look at that if I forego ssh. I do have ssh access to the server but rarely use it, so not familiar with the functions.

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.

1

u/TheRedditerater 15d ago

Thx, seems legit to me. All responses so far, including yours, suggest that the tools exist and that I just have to sit and learn those basic ssh commands.

1

u/adilbasari 14d ago

Happy it helped. And you can skip most of the ssh learning for this one task, two lines get you 90% there: on the server, find . -type f -printf '%s %p\n' > server.txt (grab it via cPanel file manager), and on Windows PowerShell, Get-ChildItem -Recurse -File | ForEach-Object { "{0} {1}" -f $_.Length, $_.FullName } | Out-File local.txt. Then sort both by size difference in any spreadsheet and the 28 GB will point at itself.

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.