You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-netapp-files/azacsnap-cmd-ref-runbefore-runafter.md
+45-17Lines changed: 45 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ services: azure-netapp-files
5
5
author: Phil-Jensen
6
6
ms.service: azure-netapp-files
7
7
ms.topic: reference
8
-
ms.date: 07/29/2022
8
+
ms.date: 02/20/2025
9
9
ms.author: phjensen
10
10
---
11
11
@@ -17,17 +17,17 @@ This article provides a guide for using the `--runbefore` and `--runafter` capab
17
17
18
18
AzAcSnap can execute external commands before or after its main execution using the options `--runbefore` or `--runafter` respectively.
19
19
20
-
`--runbefore`will run a shell command before the main execution of azacsnap and provides some of the azacsnap command-line parameters to the shell environment.
21
-
By default, `azacsnap`will wait up to 30 seconds for the external shell command to complete before killing the process and returning to azacsnap normal execution.
20
+
`--runbefore`runs a shell command before the main execution of azacsnap and provides some of the azacsnap command-line parameters to the shell environment.
21
+
By default, `azacsnap`waits up to 30 seconds for the external shell command to complete before killing the process and returning to azacsnap normal execution.
22
22
This delay can be overridden by adding a number to wait in seconds after a `%` character (for example, `--runbefore "mycommand.sh%60"` will wait up to 60 seconds for `mycommand.sh`
23
23
to complete).
24
24
25
-
`--runafter`will run a shell command after the main execution of azacsnap and provides some of the azacsnap command-line parameters to the shell environment.
26
-
By default, `azacsnap`will wait up to 30 seconds for the external shell command to complete before killing the process and returning to azacsnap normal execution.
27
-
This can be overridden by adding a number to wait in seconds after a `%` character (for example, `--runafter "mycommand.sh%60"` will wait for up to 60 seconds for `mycommand.sh`
25
+
`--runafter`runs a shell command after the main execution of azacsnap and provides some of the azacsnap command-line parameters to the shell environment.
26
+
By default, `azacsnap`waits up to 30 seconds for the external shell command to complete before killing the process and returning to azacsnap normal execution.
27
+
This delay can be overridden by adding a number to wait in seconds after a `%` character (for example, `--runafter "mycommand.sh%60"` will wait for up to 60 seconds for `mycommand.sh`
28
28
to complete).
29
29
30
-
The following list of environment variables is generated by `azacsnap`and passed to the shell forked to run the commands provided as parameters to `--runbefore` and `--runafter`:
30
+
`azacsnap` generates the following list of environment variables and passes them to the shell forked to run the commands provided as parameters to `--runbefore` and `--runafter`:
31
31
32
32
-`$azCommand` = the command option passed to -c (for example, backup, test, etc.).
33
33
-`$azConfigFileName` = the configuration filename.
@@ -39,24 +39,28 @@ The following list of environment variables is generated by `azacsnap` and passe
39
39
> [!NOTE]
40
40
> There's only a value for `$azSnapshotName` in the `--runafter` option.
41
41
42
-
### Example usage
42
+
### Example usage to back up to Azure Blob storage
43
43
44
-
An example usage for this new feature is to upload a snapshot to Azure Blob for archival purposes using the azcopy tool
44
+
> [!IMPORTANT]
45
+
> Examples are provided for informational purposes only.
46
+
> We don't guarantee the accuracy, completeness, or usefulness of any information provided.
47
+
> The use of these examples is at your own risk.
48
+
> We don't accept any liability for any loss or damage that may arise from the use of these examples.
49
+
> We don't offer support for the examples provided in this documentation.
50
+
51
+
An example usage for this new feature is to upload a snapshot to Azure Blob for archival purposes using the `azcopy` tool
45
52
([Copy or move data to Azure Storage by using AzCopy](../storage/common/storage-use-azcopy-v10.md)).
46
53
47
-
The following crontab entry is a single line and runs `azacsnap` at five past midnight. Note the call to `snapshot-to-blob.sh` passing the
This example shell script has a special stanza at the end to prevent AzAcSnap from killing the external command due to the timeout described earlier. This allows for
56
+
This example shell script has a special stanza at the end to prevent AzAcSnap from killing the external command due to the time-out described earlier. This stanza allows for
55
57
a long running command, such as uploading large files with azcopy, to be run without being prematurely stopped.
56
58
57
-
The snapshots need to be mounted on the system doing the copy, with at a minimum read-only privilege. The base location of the mount point for the snapshots should
59
+
The snapshots need to be mounted on the system doing the copy, with at a minimum read-only privilege. The base location of the mount point for the snapshots should
58
60
be provided to the `sourceDir` variable in the script.
59
61
62
+
The snapshot is uploaded as a single file by using the `tar` command to create a gzipped tarball. Putting the files into a single tarball keeps the file permissions and ownership, otherwise uploading the files individually loses these attributes.
Restoring from one of these archives stored in Azure Blob storage at a high-level is as follows:
259
+
260
+
1. Copy the snapshot archive back to the local machine. The target location should be separate from the database files and with enough capacity to allow for the file archive and the extraction, for example `/var/tmp`.
261
+
1. If they created the archive using the `--runafter` example shell script, then they can possibly extract the gzipped tarball directly from Azure Blob storage into the target location using an AzCopy pipe to tar to extract, for example:
262
+
1.`cd ${TARGET_DIRECTORY}`
263
+
1.`azcopy cp "${BLOB_STORE}/${ARCHIVE_BLOB_TGZ}?${BLOB_SAS_KEY}" --from-to BlobPipe | tar zxvf -`
264
+
1. Extract the contents of the snapshot archive.
265
+
1. Review the contents of the target location after extracting, comparing file permissions and ownership to the original database files.
266
+
1. For example, do `ls -lR`.
267
+
1. Shut down the database server processes.
268
+
1. Copy the files from the target location restored to in step 1 back to their original location.
269
+
1. Proceed with the normal database recovery process.
0 commit comments