Server management 101 -part 1: Website directory structures and Identifying folder sizes

Since getting our own dedicated server a couple of years ago we’ve had a fairly step learning curve which a lot of the time has been a tad hit-and-miss (never at the detriment of our customers I might add). Luckily we’ve had the superb support of Rackspace behind us but as others may not be so lucky, I thought I would post up a few nuggets we’ve received over the years. As I remember more, I’ll add additional posts.

Domain/Folder organisation

One of the first issues we came across (and I’m sure many people have already got into this position) was the structure of the folders on both the server and development machines. The solution we came up with was to have a common folder –for argument’s sake lets call it “WebsitesFolder”. Within “WebsitesFolder” you then create a new directory for each domain name and finally within that, a folder for each subdirectory i.e. www, blogs etc.

By creating a new folder for each subdomain, you are able to quickly find the correct folder for the domain. Then locally you are able to store the source files outside of the site’s root which will (or should) speed up your FTP transfer process as you won’t need to select which files to upload1. The structures might then look like this:
Development server

  • /domain.com
    • /www/
    • /subdomain/
    • /Source Imagery/
    • /Some Irrelevant Folder/
  • /domain2.com
    • /www/

Production server

  • /domain.com
    • /www/
    • /subdomain/
  • /domain2.com
    • /www/

1It might also be worth you checking out SyncBackSE which is an excellent FTP client that only uploads files you have changed since the last transfer. It also has the added advantage that it has customisable filters allowing you to ignore source files and folders as _notes, .cs, .vb etc. http://www.2brightsparks.com/syncback/sbse.html

Finding large directories

The other day I noticed that one of our server’s disk space was running a little low but as far as I was aware there was plenty of space left. As we tend to store all client data within set folders I was able to quickly identify that it wasn’t the client folders that was taking all the room so what was?

When you don’t know which folders are taking the space, there are a couple of tools you may find useful. The first I was told about was TreeSize (http://www.jam-software.com/freeware/index.shtml) -a free program that gives you a graphical representation of each folder’s usage:

It then allows you to quickly traverse the directory structure and identify the offending directory. There’s a load more information available through the easy-to-use interface but if all you want is a number it’s a little overkill.

The alternative to TreeSize

A heading? Just for this? Yes –this little tool is the Mac Daddy of directory size info as far as I’m concerned as it’s a free (we like free ;)) command line tool found on Microsoft’s site called “Directory Disk Usage” –DIRUSE.

DIRUSE is really easy to use, simply load up CMD and type in:
diruse /m /* c:\
and you’ll get a report of your chosen folder’s sub folders, related sizes and a count of the files within it. Ok it’s iteration can be a little slow but it gives you all the information you need quickly and easily.

The syntax is as follows:
DIRUSE [/S | /V] [/M | /K | /B] [/C] [/,] [/Q:# [/L] [/A] [/D] [/O]] [/*] DIRS

/S
Specifies whether subdirectories are included in the output.
/V
Output progress reports while scanning subdirectories.  Ignored if /S is specified.
/M
Displays disk usage in megabytes.
/K
Displays disk usage in kilobytes.
/B
Displays disk usage in bytes (default).
/C
Use Compressed size instead of apparent size.
/,
Use thousand separator when displaying sizes.
/L
Output overflows to logfile .\DIRUSE.LOG.
/*
Uses the top-level directories residing in the specified DIRS
/Q:#
Mark directories that exceed the specified size (#) with a "!".
(If /M or /K is not specified, then bytes is assumed.)
/A
Specifies that an alert is generated if specified sizes are exceeded. (The Alerter service must be running.)
/D
Displays only directories that exceed specified sizes.
/O
Specifies that subdirectories are not checked for specified size overflow.
DIRS
Specifies a list of the paths to check –you can use semicolons, commas, or spaces to separate multiple directories if required.

Note: Parameters can be typed in any order. And the '-' symbol can be used in place of the '/' symbol.

Also, if /Q is specified, then return code is ONE if any directories are found that exceed the specified sizes. Otherwise the return code is ZERO.

Example: diruse /s /m /q:1.5 /l /* c:\websitesfolder

Author

Tim

comments powered by Disqus