Finding Large Files via PowerShell
Summary:
File System backups with Carbonite Safe Server Backup (CSSB) are "file level." If a file changes, the entire file is backed up next time CSSB performs a backup that includes that file.
As a result, Incremental and/or Differential backups can be larger than expected.
Unfortunately, CSSB does not have a way to check the size of the files included in any given backup, so we must turn to Windows PowerShell to determine which files have changed.
This article applies to:
Carbonite Plans | Products | Platforms |
Power and Ultimate plans (Not sure?) | Carbonite Safe Server Backup (Not sure?) | Windows |
Solution:
Find the Large Files via Windows PowerShell
- Open Windows PowerShell by any means.
- Example: Open your Start Menu and type "PowerShell".
- Paste the following command and then press Enter:
Get-ChildItem -Path (Read-Host -Prompt 'Enter path') -Recurse -Force | Where-Object{$_.LastWriteTime -gt (Get-Date).AddDays(-3)} | sort -Descending -Property length | select -First 100 | Format-Table -Wrap -Property length, lastwritetime, fullname
- This command will prompt you to enter a drive or path to scan:
- You must end this path with a \ character.
- Example 1: C:\
- Example 2: \\Some\Network\Folder\
- Example 3: D:\Some\Folder\
Command Details
- The command will scan all sub-folders within the path you provide and return the 100 largest files modified in the last 3 days.
- Please be patient. There is no progress bar or other display of progress.
- Paths that contain many files/folders will take longer to scan.
- Results will be displayed within the PowerShell window once the scan is complete.
- If you wish to output to a file instead, please see the modified command below.
- This command assumes you have permission to access the folder, drive, or network location you choose.
- It will not prompt you for credentials. Instead, errors will be displayed if a path cannot be scanned for any reason.
- It is normal for some paths to be inaccessible.
- Certain system folders, such as C:\Windows\, are most likely to throw access errors.
- Use Run As Administrator when opening PowerShell to reduce the number of access issues.
- File size is returned in bytes.
- You may download this command in .ps1 script format here. (Unzip the downloaded file for the .ps1 file)
Modifying the Command
- You can change many things about this command, such as the number of items to return or how far back to look.
- The number of files returned is controlled in the "select -First" part of the command. Change the number to change the number of files returned.
- Example: Enter 200 to return the 200 largest files.
- The timeframe is controlled in the "(Get-Date).AddDays" command. Change the number to change the number of days. This number must be negative.
- Examples: Enter -3 for the last three days. Enter -7 for the last week. And so on.
- You may also change the command to output to a file instead of within the PowerShell Window. For convenience, here is the modified command:
Get-ChildItem -Path (Read-Host -Prompt 'Enter path') -Recurse -Force | Where-Object{$_.LastWriteTime -gt (Get-Date).AddDays(-3)} | sort -Descending -Property length | select -First 100 | Format-Table -Wrap -Property length, lastwritetime, fullname | Out-File C:\Some\Folder\SomeName.txt
- You must supply a valid path for the output file at the end of the command.