The information contained in this article has been verified as up-to-date on the date of the original publication of the article. HashiCorp endeavors to keep this information up-to-date and correct, but it makes no representations or warranties of any kind, express or implied, about the ongoing completeness, accuracy, reliability, or suitability of the information provided.
All information contained in this article is for general information purposes only. Any reliance you place on such information as it applies to your use of your HashiCorp product is therefore strictly at your own risk.
Introduction
Problem
A manual snapshot is recommended in the General Upgrade Process for Consul. In earlier versions of Consul, users will run into the following error when running the command consul snapshot save
on a Windows Operating System (OS).
- Windows Server 2016, Consul 1.8.5+ent
-
PS C:\Hashicorp\Consul> .\consul.exe snapshot save testbkup.test
Error writing unverified snapshot file: chmod snap.test.unverified.tmp161459347: not supported by windows
-
- Windows Server 2019 Standard, Consul 1.10.12.
-
PS C:\Hashicorp\Consul> consul snapshot save testbkup.snapError writing unverified snapshot file: sync .: The handle is invalid.Error writing unverified snapshot file: chmod snap.test.unverified.tmp161459347: not supported by windows
-
- Windows Server 2019 Datacenter, Consul 1.15.2.
-
PS C:\Hashicorp\Consul> consul snapshot save testbkup.snap
Error writing unverified snapshot file: sync .: Access is denied.
-
This may result in an “unverified” snapshot file being created.
testbkup.snap.unverified
Cause
- An fsync function gets called when using the snapshot save command and Windows OS does not handle POSIX (Portable Operating System Interface) commands.
The snapshot issue for Windows OS is fixed in later versions of Consul (1.14.9, 1.16.1, and 1.15.5 and above).
- snapshot: fix access denied and handle is invalid when we call snapshot save on windows - skip sync() for folders in windows in rboyer/safeio#3 [GH-18302]
Prerequisites
- Download a fixed version of Consul and unzip the file to a new directory.
Solution:
You will use a fixed version's binary to run the Consul Snapshot command in parallel on the existing Consul installation.
-
Change to the directory where the fixed binary was downloaded to invoke
consul info
to check functionality.- This example demonstrates how the
consul info
command, when run with the1.14.9+ent
binary successfully interfaces with and retrieves information from a running binary of version1.8.5+ent
.
PS C:\Users\Consul\consul_1.14.9_windows_amd64> .\consul.exe info
...
build:
prerelease =
revision = e7100971
version = 1.8.5+ent
consul:
acl = disabled
bootstrap = true
known_datacenters = 1
leader = true
leader_addr = 10.128.0.2:8300
server = true
...
- This example demonstrates how the
- Now that you verified the new binary can interface with the running Cluster, you can run the
consul snapshot save testbkup.test
command.
PS C:\Users\Consul\consul_1.14.9+ent_windows_amd64> .\consul.exe snapshot save testbkup.test
Saved and verified snapshot to index 598
PS C:\Users\Consul\consul_1.14.9+ent_windows_amd64> ls
Directory: C:\\Users\\Consul\\consul_1.14.9+ent_windows_amd64
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 1/31/2024 4:54 PM 162026160 consul.exe
-a---- 1/31/2024 4:54 PM 31486 EULA.txt
-a---- 1/31/2024 4:57 PM 1753 testbkup.test
-a---- 1/31/2024 4:54 PM 9518 TermsOfEvaluation.txt
Outcome
Using an updated Consul binary enables Consul system administrators to capture manual snapshots, ensuring smooth and uninterrupted upgrades for their Consul cluster.