1---
2layout: "language"
3page_title: "Backend Type: local"
4sidebar_current: "docs-backends-types-enhanced-local"
5description: |-
6  Terraform can store the state remotely, making it easier to version and work with in a team.
7---
8
9# local
10
11**Kind: Enhanced**
12
13The local backend stores state on the local filesystem, locks that
14state using system APIs, and performs operations locally.
15
16## Example Configuration
17
18```hcl
19terraform {
20  backend "local" {
21    path = "relative/path/to/terraform.tfstate"
22  }
23}
24```
25
26## Data Source Configuration
27
28```hcl
29data "terraform_remote_state" "foo" {
30  backend = "local"
31
32  config = {
33    path = "${path.module}/../../terraform.tfstate"
34  }
35}
36```
37
38## Configuration variables
39
40The following configuration options are supported:
41
42 * `path` - (Optional) The path to the `tfstate` file. This defaults to
43   "terraform.tfstate" relative to the root module by default.
44 * `workspace_dir` - (Optional) The path to non-default workspaces.
45
46## Command Line Arguments
47
48~> This section describes legacy features that we've preserved for backward
49compatibility but that we no longer recommend. See below for more details.
50
51For configurations that include a `backend "local"` block or that default to
52the local backend by not specifying a backend at all, most commands that either
53read or write state snapshots from the backend accept the following
54additional arguments:
55
56* `-state=FILENAME` - overrides the state filename when _reading_ the prior
57  state snapshot.
58* `-state-out=FILENAME` - overrides the state filename when _writing_ new state
59  snapshots.
60
61    If you use `-state` without also using `-state-out` then Terraform will
62    use the `-state` filename for both `-state` and `-state-out`, which means
63    Terraform will overwrite the input file if it creates a new state snapshot.
64* `-backup=FILENAME` - overrides the default filename that the local backend
65  would normally choose dynamically to create backup files when it writes new
66  state.
67
68    If you use `-state` without also using `-backup` then Terraform will use
69    the `-state` filename as a filename prefix for generating a backup filename.
70    You can use `-backup=-` (that is, set the filename to just the ASCII
71    dash character) to disable the creation of backup files altogether.
72
73These three options are preserved for backward-compatibility with earlier
74workflows that predated the introduction of built-in remote state, where
75users would write wrapper scripts that fetch prior state before running
76Terraform and then save the new state after Terraform exits, in which case
77the three arguments would typically all be paths within a temporary
78directory used just for one operation.
79
80Because these old workflows predate the introduction of the possibility of
81[multiple workspaces](/docs/language/state/workspaces.html), setting them
82overrides Terraform's usual behavior of selecting a different state filename
83based on the selected workspace. If you use all three of these options then
84the selected workspace has no effect on which filenames Terraform will select
85for state files, and so you'll need to select different filenames yourself if
86you wish to keep workspace state files distinct from one another.
87
88These three options have no effect for configurations that have a different
89backend type selected.
90
91We do not recommend using these options in new systems, even if you are running
92Terraform in automation. Instead,
93[select a different backend which supports remote state](./) and configure it
94within your root module, which ensures that everyone working on your
95configuration will automatically retrieve and store state in the correct shared
96location without any special command line options.
97