Include and exclude files for backup

Overview

This article provides a high-level overview of the many ways end users and administrators can include and exclude files for backups. You may want to include or exclude files for backups for many reasons, such as to ensure you back up only high-value files, to reduce network traffic, and to keep archive size manageable.

Considerations

Include and exclude files using the Code42 agent

Users of the Code42 agent can include and exclude files for backups with the following methods.

Type of exclusion Description
Manage files Include and exclude files for backup.
File exclusions Excludes file types from backup such as mp3 and wmv.

Manage files

Users of the Code42 agent use the Manage Files view to select files for backup. Any files not selected are excluded from backup. For more information, see Change the file selection.

To prevent users from changing the file selection in the Code42 agent, lock the file selection exclusions in the Code42 console. Locking this setting helps prevent data loss and mitigates potential security issues.

  1. In the Code42 agent, click Manage Files. 
  2. Select only those files you want to back up. Any files you do not select are excluded from backup.
  3. To remove previously-selected files from backup:
    1. Navigate to the drive, folder, or files that you want to remove, then deselect the check box next to any item you want to delete from your backup.
    2. Click Save.
      If you deselected any files or folders, the Delete Files from Backup warning displays.
    3. If applicable, select I understand to confirm you want to delete deselected files from your backup.
    4. If applicable, select Delete.
  4. To ensure that file inclusions and exclusions are processed by the Code42 agent, initiate a file verification scan by selecting Scan for file changes from the Backup Set Settings Menu

File exclusions

Users of the Code42 agent use the File Exclusions setting to specify file types to exclude from backup, for example, mp3, wmv, etc. For more information, see Exclude or filter files using file type and regular expressions (regex).

To prevent users from changing file exclusions in the Code42 agent, lock the filename exclusions in the Code42 console. Locking this setting helps prevent data loss and mitigates potential security issues.

  1. In the Code42 agent, choose Settings in the upper-right corner.
  2. In the Device Preferences pane, choose Backup Sets.
  3. To the right of File Exclusions, click Change.
    The File Exclusions dialog appears.
    File exclusions in the Code42 app
  4. To exclude file types, type the file extensions in the provided field and click Add.
    Select Use regular expression to exclude files using regular expressions.
  5. Click Save.

Include and exclude files using the Code42 console

You can include and exclude files for backups using the following methods.

Type of exclusion Description
File selection Includes and excludes files and directories for backup.
Filename exclusions Excludes file types from backup such as mp3 and wmv.
Hidden filenames Hides files and folders from appearing in file selections in the Code42 agent so users cannot select them for backup or restore.
Global exclusions Excludes files from backup no matter where the files are being backed up, whether to local storage (for example, an external drive) or to Code42 cloud storage. Files selected with this setting are also removed from all archives. 
Cloud exclusions Excludes files from backup to Code42 cloud storage, but not from local storage (for example, external drives). Files selected with this setting are also removed from Code42 cloud archives.  

File selection

Use the File selection pane to specify files and directories to include and exclude for backup.  

  1. Choose Administration > Environment > Organizations.
  2. Select an organization.
  3. Select Actions > Device backup defaults.
  4. On the General tab, if necessary, deselect Use device defaults from parent.
  5. Select the Backup tab.
  6. Navigate to File selection.
    File selection
  7. In the Included files field, add file names and directories that should be included in backups. In the Excluded files field, add file names and directories that should be excluded from backups.
    In addition to adding files names and directories, you can also use substitution variables.
  8. To apply the settings, push Push button them to devices, or lock Unlock button them to prevent users from changing file selections in the Code42 agent.

Video

Watch the video below to learn how to change backup file selection. For more videos, visit the Code42 University

Updated Code42 console interface
Some menu and navigation items shown in this video have changed. Follow the steps in this article to navigate to these settings, then watch the video for more details.

Filename exclusions

Use the Filename exclusions pane to specify file types to exclude from backup, for example, mp3, wmv, etc. 

  1. Choose Administration > Environment > Organizations.
  2. Select an organization.
  3. Select Actions > Device backup defaults.
  4. On the General tab, if necessary, deselect Use device defaults from parent.
  5. Select the Backup tab.
  6. Navigate to Filename exclusions.
    Filename exclusions
  7. Choose the platform for which you want to set the exclusion.
  8. Choose Regular Expression if you want to add exclusions using regular expressions.
  9. In the field provided, enter the file types to exclude, for example, mp3, avi, etc., or enter regular expressions for file types.
    You can also use choose Import to import a text file to add to the list of exclusions, or choose Export to export the existing list of exclusions so you can edit it and then import it.
  10. To apply the settings, push Push button them to devices, or lock Unlock button them to prevent users from changing file exclusions in the Code42 agent.

Video

Watch the video below to learn how to set filename exclusions. For more videos, visit the Code42 University

Updated Code42 console interface
Some menu and navigation items shown in this video have changed. Follow the steps in this article to navigate to these settings, then watch the video for more details.

Hidden filenames

Use the Hidden filenames pane to hide files and folders from appearing in file selections in the Code42 agent. Because these files and folders are hidden, users cannot select them for backup or restore. 

  1. Choose Administration > Environment > Organizations.
  2. Select an organization.
  3. Select Actions > Device backup defaults.
  4. On the General tab, if necessary, deselect Use device defaults from parent.
  5. Select the Backup tab.
  6. Navigate to Hidden filenames.
    Hidden filenames
  7. Choose the platform for which you want to set the exclusion.
  8. Choose Regular Expression if you want to add exclusions using regular expressions.
  9. In the field provided, add filenames and path names of directories that should be hidden from selection for backup or restore.
    You can also choose Import to import a text file to add to the list of exclusions, or choose Export to export the existing list of exclusions so you can edit it and then import it.
  10. To apply the settings, push Push button them to devices, or lock Unlock button them to prevent the settings from being changed.

Video

Watch the video below to learn how to work with hidden filenames settings. For more videos, visit the Code42 University

Updated Code42 console interface
Some menu and navigation items shown in this video have changed. Follow the steps in this article to navigate to these settings, then watch the video for more details.

Global exclusions

Use the Global exclusions pane to exclude files from backup no matter where the files are being backed up, whether to local storage (for example, an external drive) or to Code42 cloud storage. Files selected with this setting are also removed from all archives. Global Exclusions also apply to all preservation policies

  1. Choose Administration > Environment > Organizations.
  2. Select an organization.
  3. Select Actions > Device backup defaults.
  4. On the General tab, if necessary, deselect Use device defaults from parent.
  5. Select the Backup tab.
  6. Navigate to Global exclusions.
    Global exclusions
  7. Choose the platform for which you want to set the exclusion.
  8. Choose Regular Expression if you want to add exclusions using regular expressions.
  9. In the field provided, add filenames and path names of directories that should be excluded from existing archives and future backups.
    You can also choose Import to import a text file to add to the list of exclusions, or choose Export to export the existing list of exclusions so you can edit it and then import it.
  10. To apply the settings, push Push button them to devices, or lock Unlock button them to prevent the settings from being changed.

Video

Watch the video below to find how to work with global and cloud exclusions. For more videos, visit the Code42 University

Updated Code42 console interface
Some menu and navigation items shown in this video have changed. Follow the steps in this article to navigate to these settings, then watch the video for more details.

Recommended global exclusions 

We recommend you set the following global exclusions, to optimize file backups:

(?i)^.*(\.class|-journal|\.Win386\.SWP|PM_HIBER\.BIN|SAVE2DSK\.BIN|SYSTEM\.DAT|TOSHIBER\.DAT|Thumbs\.db|USER\.DAT|\.bck|\.bkf|\.cdt|\.hdd|\.hds|\.icloud|\.ini|\.lrprev|\.manifest|\.mum|\.nib|\.nvram|\.ost|\.part|\.pvm|\.pvs|\.rbf|\.tibx?|\.tmp|\.upd|\.avhdx|\.ova|\.vdi|\.vfd|\.vhd|\.vhdx|\.vmc|\.vmdk|\.vmem|\.vmsd|\.vmsn|\.vmss|\.vmtm|\.vmwarevm|\.vmx|\.vmxf|\.vsv|\.vud|\.xva|\.qcow2?|iso|pkg|raw|memory\.dmp|/Lightroom.*Previews\.lrdata|\.sparsebundle|\.sparseimage|/(cookies|permissions)\.sqlite(-.{3})?|\.crdownload)$
(?i)^.*(/Apple.*/Installer Cache/|/Cache/|/Cookies/|/Music/Subscription/|/Plex Media Server/|/Steam/|/Temp/|/\.dropbox\.cache/|/\.git/|/iPod Photo Cache/|/node_modules/|/tmp/|/tsm_images/|\.Trash|\.hdd/|\.pvm/|\.cprestoretmp|\.nvm|\.npm|/\.gradle/).*
linux:(?i)^/(usr/(?!($|local/$|local/crashplan/$|local/crashplan/print_job_data/.*))|opt/|etc/|dev/|home/[^/]+/\.config/google-chrome/|home/[^/]+/\.mozilla/|sbin/).*
linux:^/(cdrom/|dev/fd/|devices/|dvdrom/|initrd/|kernel/|lost\+found/|proc/|run/|selinux/|srv/|sys/|system/|var/(:?run|lock|spool|tmp|cache)/|proc/).*
linux:^/lib/modules/.*/volatile/\.mounted
mac:(?i)^.*(/iTunes/Album Artwork/Cache/|/Network Trash Folder/|/Photos Library.*/Thumbnails/|/backups\.backupdb/|/iP.* Software Updates/|/iPhoto Library.*/Thumbnails/|/iPhoto Library/iPod Photo Cache|/migratedphotolibrary/Thumbnails/|\.imovielibrary/.*/Analysis Files/|\.imovielibrary/.*/Render Files/).*
mac:^.*(/Trash/|/\.fcpcache/|MobileBackups/|\.Spotlight-.*/|\.fseventsd|\.hotfiles\.btree|/bin/|/home/|/sbin/|/cores/|/private/|/var/).*
mac:(?i)^.*(\.imovielibrary/\.lock)$
mac:(?i)^.*(\.DS_Store|\.plist|\.strings)$
mac:(?i)^/(usr/|opt/|etc/|var/|Users/((?!XCode).)*/Applications/|Users/Shared/|dev/|Library/(?!($|Application Support/$|Application Support/CrashPlan/$|Application Support/CrashPlan/print_job_data/.*))|proc/|Users/.*/.vscode/extensions/).*
mac:^/(Applications/|Desktop DB|Desktop DF|Network/|Previous Systems|System/|Users/.*/\.cisco/vpn/log/|Users/.*/\.dropbox/|Users/[^/]+/Library/|\.DocumentRevisions-V100/|\.PKInstallSandboxManager-SystemSoftware|\.adobeTemp/|\.vol/|afs/|automount/|lost\+found/|net/).*
win:(?i)^.*(/I386|/System Volume Information/|/Temporary Internet Files/|/Windows Update Setup Files/|\$RECYCLE\.BIN/|/NTUSER|/Safari/Library/Caches/|/Windows Defender/|/cygwin(64)?/(bin|dev|etc|lib|sbin|tmp|var|usr)/|UsrClass\.dat).*
win:^.*(/Local Settings/Temp|/Local.*/History/|/LocalService/|/MSOCache|/NetHood/|/NetworkService/).*
win:(?i)^.*(/pagefile\.sys|\.etl|\.mui)$
win:(?i)^.:/(Recovery/|boot/|ESD/|Recycler/|Dell/|Intel/|Oracle/|PerfLogs/|Program Files( \(x86\))?/|ProgramData/(?!$|CrashPlan/$|CrashPlan/user_settings/)|Users/All Users/|Users/[^/]+/AppData/|Users/[^/]+/Apple/MobileSync/|Windows(\.old)?/|\$WINDOWS.~(BT|WS)/|\$SysReset/|\$GetCurrent/|_RESTORE/|_SMSTaskSequence/|safeboot/|swsetup/).*
win:(?i)^.:/(Config\.Msi|HIBERFIL\.SYS|HIBRN8\.DAT|autoexec\.bat|boot\.ini|bootmgr|bootnxt|bootsect\.bak|config\.sys|io\.sys|msdos\.sys|ntdetect\.com|ntldr|swapfile\.sys)$
(?i)^.*(\.kgdb|\.db|\.srd|-shm|-wal|-lock|\.musicdb|\.tvdb|\.pid)$
(?i)^.*\.photoslibrary/(private/|resources/|database/).*$
(?i)^.*/(.*\.?leveldb)/.*$

Cloud exclusions

Use the Cloud exclusions pane to exclude files from backup to Code42 cloud storage, but not from local storage (for example, external drives). Files selected with this setting are also removed from Code42 cloud archives.

  1. Choose Administration > Environment > Organizations.
  2. Select an organization.
  3. Select Actions > Device backup defaults.
  4. On the General tab, if necessary, deselect Use device defaults from parent.
  5. Select the Backup tab.
  6. Navigate to Cloud exclusions.
    Cloud exclusions
  7. Choose the platform for which you want to set the exclusion.
  8. Choose Regular Expression if you want to add exclusions using regular expressions.
  9. In the field provided, add filenames and path names of directories that should be excluded from existing Code42 cloud archives and future backups to the Code42 cloud.
    You can also choose Import to import a text file to add to the list of exclusions, or choose Export to export the existing list of exclusions so you can edit it and import it.
  10. To apply the settings, push Push button them to devices, or lock Unlock button them to prevent the settings from being changed.

Exclude files using the Code42 API

Use the Code42 API /exclusions resource to define a list of file types and file paths to exclude from collection using regex expressions. You can use the API to set global, cloud, and filename exclusions.

Using the API overwrites existing exclusions
Using the /exclusions/update resource to set file exclusions overwrites existing exclusions, including those exclusions set in the Code42 console. Before using the /exclusions/update resource to change exclusions, run the /exclusions/view resource to gather existing exclusions for exclusion types GLOBAL, CLOUD, and USER (filename).

Examples

To view current file exclusions, use the /exclusions/view resource. For example, run the following example to view global exclusions:

curl -X GET 'https://console.us.code42.com/api/v10/exclusions/view/?orgId=<orgId>&exclusionType=GLOBAL' -H 'content-type: application/json' -H "authorization: Bearer <AuthToken>"

To exclude files, use the /exclusions/update  API resource. For example, run the following example to update global exclusions:

curl -X POST 'https://console.us.code42.com/api/v10/exclusions/update' 
-H 'content-type: application/json' 
-H "authorization: Bearer <AuthToken>" -d '{"orgId": "<OrgID>", "exclusionSet": {"allOs": ["'\''.*cache.*'\''"], "windows": ["'\''.*.etl'\''","'\''.*/AppData/.*'\''"],"macintosh": ["'\''.*.db'\''"],"linux": ["'\''.*.db'\''"] },"regex": true, "exclusionType": "GLOBAL", "lock": false, "pushToInheritingOrgs": true, "pushToAllOrgs": false }'

In these examples:

  • Replace <AuthToken> with an authentication token
  • Replace <OrgID> with your organization's ID. 
  • For the exclusionType  value use:
    • GLOBAL  for global exclusions
    • CLOUD  for cloud exclusions
    • USER  for filename exclusions

Summary

  • Request URL 
    • United States:
      • If you sign in to the Code42 console at https://console.us.code42.com (US1), use
        https:/console.us.code42.com/api/v10/exclusions/ 

      • If you sign in to the Code42 console at https://console.us2.code42.com (US2), use:
        https://console.us2.code42.code42.com/api/v10/exclusions/
      • If you sign in to the Code42 console for the Code42 federal environment at https://console.gov.code42.com (US3), use: 
        https://console.gov.code42.com/api/v10/exclusions/ 
    • Ireland: 
  • Exclusions API resource names: 
    • view : View current file exclusions
    • update : Update file exclusions
  • Authentication method: Include an authentication token in the request header.
  • Organization ID: To obtain the orgId for all organizations:
    1. In the Code42 console, go to Administration > Environment > Organizations.
    2. Click Export.
      A CSV file is downloaded to your device.
    3. Open the exported file and review the orgId column.
  • For more information about Code42 API syntax, see Code42 API syntax and usage.

Exclude files from File Metadata Collection

File Metadata Collection captures information about files on user devices and stored in cloud services. You can use the Code42 API to define a list of file types and file paths to exclude from collection. For directions, see File Metadata Collection exclusions via API.