3

Is there a way to schedule a GDB on an SQL server to automatically compress once a day? As of right now I need to remember to open catalog and compress a Geodatabase manually everyday.

  • What's the process you use for compression? – geoJshaun Feb 10 '17 at 18:24
  • Which version of ArcGIS is on your server? – Midavalo Feb 10 '17 at 18:48
3

In ArcToolbox > Data Management Tools > Geodatabase Administration there is a tool Compress.

If you run this tool (once) and copy python snippet from the completed result into a python file, you can schedule a batch file to run that python file.

You can schedule any ArcToolbox tool this way.

Python file:

import arcpy
arcpy.Compress_management(r"c:\connections\gdbconnection.sde")

Batch file:

python.exe c:\script\mycompress.py

Schedule this batch file in Windows Scheduled Tasks.

1

You can compress the database using sdeversion command line tool (you have to fill in with your properties):

sdeversion -o compress [-N] -u <ArcSDE_Admin_user_name> 
                       [-p <ArcSDE_Admin_user_password>] 
                       [-q] [-i <service> | <port#> | <direct connection>] 
                       [-s <server_name>] 
                       [-D <database_name>]

You may also wish to run the sdemon -o kill -t all command to disconnect all pending connections if you face problems with locks on DB tables while executing script from above.

sdemon -o kill -t <{ all | pid }> 
                  [-p <ArcSDE_admin_password>] [-N]
                  {[-i <service> | <port#> | <direct_connect_info>]
                  {[-s <server_name>] | [-H <sde_directory>]}
                  [-u <user_name>] [-p <user_password>] [-D <database_name>]

And you can put this scripts to a batch file on server and schedule to run this script at your prefered time and frequency. In example if you're in control of Windows server you will set this script to work with Task Scheduler, on Linux you have cron job.

  • I believe that this will work for older ArcSDE installs (v 8.x, 9.x, 10.0) but not for 10.1 or newer, as I think they removed the sde command line tools at 10.1 – Midavalo Feb 10 '17 at 18:51
  • @Midavalo Thanks for your comment! Command line tools are supported up to geodatabases version 10.2.2. At version 10.3 they are no longer available and migrating workflows to ArcPy is recommended, as I read here support.esri.com/technical-article/000012433 - good to know before upgrading – d324223 Feb 10 '17 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.