How do I copy a geodatabase to a different location using arcpy?

2922
5
Jump to solution
07-30-2018 03:03 PM
vonmoosa
MVP

I'm wanting to make a copy of a geodatabase from one location on our network to another. Can anyone help?

0 Kudos
1 Solution

Accepted Solutions
vonmoosa
MVP

Thanks for the help. Below is my final script I came up with that has been tested and works.

import arcpy
from arcpy import env
arcpy.env.overwriteOutput = True

env.workspace = r"M:\GIS Geodatabases"
arcpy.Copy_management("Cadastral.gdb", r"T:\pl\Planning Geodatabases\Cadastral.gdb")

print "Cadastral.gdb Copy Complete"

env.workspace = r"M:\GIS Geodatabases"
arcpy.Copy_management("Transportation.gdb", r"T:\pl\Planning Geodatabases\Transportation.gdb")

print "Transportation.gdb Copy Complete"

env.workspace = r"M:\GIS Geodatabases"
arcpy.Copy_management("AdminBoundaries.gdb", r"T:\pl\Planning Geodatabases\AdminBoundaries.gdb")

print "AdminBoundaries.gdb Copy Complete"

View solution in original post

0 Kudos
5 Replies
JoeBorgione
MVP Esteemed Contributor

I started writing out some code, but check this: Copy—Help | ArcGIS Desktop   it's pretty easy...

That should just about do it....
vonmoosa
MVP

Thanks for the help. Below is my final script I came up with that has been tested and works.

import arcpy
from arcpy import env
arcpy.env.overwriteOutput = True

env.workspace = r"M:\GIS Geodatabases"
arcpy.Copy_management("Cadastral.gdb", r"T:\pl\Planning Geodatabases\Cadastral.gdb")

print "Cadastral.gdb Copy Complete"

env.workspace = r"M:\GIS Geodatabases"
arcpy.Copy_management("Transportation.gdb", r"T:\pl\Planning Geodatabases\Transportation.gdb")

print "Transportation.gdb Copy Complete"

env.workspace = r"M:\GIS Geodatabases"
arcpy.Copy_management("AdminBoundaries.gdb", r"T:\pl\Planning Geodatabases\AdminBoundaries.gdb")

print "AdminBoundaries.gdb Copy Complete"
0 Kudos
JoeBorgione
MVP Esteemed Contributor

Good job; you only need to set your workspace once, so lines 10 & 14 aren't needed. If you want to have some fun, create a list of the the database names and iterate through them in a 'for' loop....

That should just about do it....
0 Kudos
vonmoosa
MVP

I'm pretty new to Python but thanks for the input. I will have to give that a try so I can sharpen my skills.

0 Kudos
JoeBorgione
MVP Esteemed Contributor

Stick with it and have some fun.  Anytime you need to do something more than a couple of times, script it.  There is only one way to get into python, and that's to get into python!  A year ago I couldn't spell python...

That should just about do it....