# import

The .import() method for the SurrealDB Rust SDK restores the database from a file.

**3.x**

Restores the database from a file.

> [!NOTE]
> WebSocket connections currently do not support exports and imports. Be sure to use an HTTP endpoint and the `protocol-http` feature when using this method.

```rust title="Method Syntax"
db.import(source)
```

## Example usage

The following example assumes the presence of a file called `backup.surql` in the same directory as the current project. To quickly create it, copy and paste [the example for the .export() method](/docs/reference/rust/methods/export.md).

```rust
use surrealdb::engine::any::connect;
use surrealdb::opt::auth::Root;

#[tokio::main]
async fn main() -> surrealdb::Result<()> {
    let db = connect("http://localhost:8000").await?;
    db.signin(Root {
        username: "root".to_string(),
        password: "secret".to_string(),
    })
    .await?;
    db.use_ns("main").use_db("main").await?;
    db.import("backup.surql").await?;
    Ok(())
}
```

## See also

* [.import() method on Docs.rs](https://docs.rs/surrealdb/latest/surrealdb/struct.Surreal.html#method.import)

**2.x**

Restores the database from a file.

> [!NOTE]
> WebSocket connections currently do not support exports and imports. Be sure to use an HTTP endpoint when using this method.

```rust title="Method Syntax"
db.import(source)
```

## Example usage

```rust
use surrealdb::engine::any::connect;
use surrealdb::opt::auth::Root;

#[tokio::main]
async fn main() -> surrealdb::Result<()> {
    let db = connect("http://localhost:8000").await?;
    db.signin(Root {
        username: "root",
        password: "secret",
    })
    .await?;
    db.use_ns("main").use_db("main").await?;
    db.import("backup.surql").await?;
    Ok(())
}
```

## See also

* [.import() method on Docs.rs](https://docs.rs/surrealdb/latest/surrealdb/struct.Surreal.html#method.import)
