# Error with "Copy to"

**URL:** <https://community.cratedb.com/t/error-with-copy-to/50>\
**Category:** SQL\
**Created:** [November 6, 2018, 2:44pm UTC](https://community.cratedb.com/t/error-with-copy-to/50 "2018-11-06T14:44:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![roman](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/roman/32/36_2.png) [@roman](https://community.cratedb.com/u/roman)\
**Post date:** [November 6, 2018, 2:44pm UTC](https://community.cratedb.com/t/error-with-copy-to/50/1 "2018-11-06T14:44:09Z")

</div>

Hi I am receiving thie error when doing COPY TO with crate command:

> crash --hosts 127.0.0.1 -c “copy metermaster22 to DIRECTORY ‘/crateBackup’”  
> CONNECT OK  
> SQLActionException[NotSerializableExceptionWrapper: unhandled\_server\_exception: Failed to open output: ‘/crateBackup/metermaster22\_2\_.json (No such file or directory)’]

---

<div class="post-metadata">

**Author:** ![roman](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/roman/32/36_2.png) [@roman](https://community.cratedb.com/u/roman)\
**Post date:** [November 6, 2018, 2:44pm UTC](https://community.cratedb.com/t/error-with-copy-to/50/2 "2018-11-06T14:44:44Z")

</div>

I tried to recreate the error, are you sure that the ‘/crateBackup’ exists?

---

<div class="post-metadata">

**Author:** ![senchi](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/senchi/32/83_2.png) [@senchi](https://community.cratedb.com/u/senchi)\
**Post date:** [February 18, 2019, 12:40pm UTC](https://community.cratedb.com/t/error-with-copy-to/50/3 "2019-02-18T12:40:01Z")

</div>

Hi,

I’m having exactly the same problem.  
We have a install/deployment script which always does the same:

1. remove all json files from backup dir
2. create new backup files via COPY TO DIRECTORY

This is what I keep getting, and it is not always on the same table too!

```auto
curl -H 'Content-Type: application/json' -sSXPOST 'localhost:4200/_sql?pretty' -d@- << EOF
 {"stmt":"COPY bookndrive.\"station\" TO DIRECTORY ?", "args":["/opt/norepos/data/tmp"]}
EOF
{
  "error" : {
    "message" : "SQLActionException[NotSerializableExceptionWrapper: unhandled_server_exception: Failed to open output: '/opt/norepos/data/tmp/station_0_.json (No such file or directory)']",
    "code" : 5000
  }
}

```

Any idea how we can pinpoint the exact cause of this?

---

<div class="post-metadata">

**Author:** ![roman](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/roman/32/36_2.png) [@roman](https://community.cratedb.com/u/roman)\
**Post date:** [February 20, 2019, 9:37am UTC](https://community.cratedb.com/t/error-with-copy-to/50/4 "2019-02-20T09:37:35Z")

</div>

Hi @senchi,

Did you check if the target directory exists?
