Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
haf_api_node
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
haf_api_node
Commits
c39990f0
Commit
c39990f0
authored
1 year ago
by
Eric Frias
Browse files
Options
Downloads
Patches
Plain Diff
Make zfs snapshot scripts more resilient
parent
31f1112b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
create_zfs_datasets.sh
+17
-3
17 additions, 3 deletions
create_zfs_datasets.sh
snapshot_zfs_datasets.sh
+73
-17
73 additions, 17 deletions
snapshot_zfs_datasets.sh
with
90 additions
and
20 deletions
create_zfs_datasets.sh
+
17
−
3
View file @
c39990f0
...
@@ -45,9 +45,23 @@ while true; do
...
@@ -45,9 +45,23 @@ while true; do
esac
esac
done
done
if
[
!
-z
"
$ENV_FILE
"
]
;
then
if
[
-z
"
$ZPOOL
"
-o
-z
"
$TOP_LEVEL_DATASET
"
]
;
then
echo
reading
$ENV_FILE
if
[
!
-z
"
$ENV_FILE
"
]
;
then
.
$ENV_FILE
echo
reading
$ENV_FILE
.
$ENV_FILE
elif
[
-f
.env
]
;
then
echo
reading configuration from .env
.
./.env
else
echo
"You must either provide an --env-file argument or both a --zpool and --top-level-dataset"
echo
"argument to tell this script what to create."
exit
1
fi
fi
if
[
-z
"
$ZPOOL
"
-o
-z
"
$TOP_LEVEL_DATASET
"
]
;
then
echo
"Your environment file must define the ZPOOL and TOP_LEVEL_DATASET environment variables"
exit
1
fi
fi
[
-z
"
$ZPOOL_MOUNT_POINT
"
]
&&
ZPOOL_MOUNT_POINT
=
"/
$ZPOOL
"
[
-z
"
$ZPOOL_MOUNT_POINT
"
]
&&
ZPOOL_MOUNT_POINT
=
"/
$ZPOOL
"
...
...
This diff is collapsed.
Click to expand it.
snapshot_zfs_datasets.sh
+
73
−
17
View file @
c39990f0
...
@@ -45,17 +45,31 @@ while true; do
...
@@ -45,17 +45,31 @@ while true; do
esac
esac
done
done
if
[
-z
"
$ZPOOL
"
-o
-z
"
$TOP_LEVEL_DATASET
"
]
;
then
if
[
!
-z
"
$ENV_FILE
"
]
;
then
echo
reading
$ENV_FILE
.
$ENV_FILE
elif
[
-f
.env
]
;
then
echo
reading configuration from .env
.
./.env
else
echo
"You must either provide an --env-file argument or both a --zpool and --top-level-dataset"
echo
"argument to tell this script what to create."
exit
1
fi
fi
if
[
-z
"
$ZPOOL
"
-o
-z
"
$TOP_LEVEL_DATASET
"
]
;
then
echo
"Your environment file must define the ZPOOL and TOP_LEVEL_DATASET environment variables"
exit
1
fi
SNAPSHOT_NAME
=
"
$1
"
SNAPSHOT_NAME
=
"
$1
"
if
[
-z
"
$SNAPSHOT_NAME
"
]
;
then
if
[
-z
"
$SNAPSHOT_NAME
"
]
;
then
echo
"No snapshot name provided"
echo
"No snapshot name provided"
exit
1
exit
1
fi
fi
if
[
!
-z
"
$ENV_FILE
"
]
;
then
echo
reading
$ENV_FILE
.
$ENV_FILE
fi
[
-z
"
$ZPOOL_MOUNT_POINT
"
]
&&
ZPOOL_MOUNT_POINT
=
"/
$ZPOOL
"
[
-z
"
$ZPOOL_MOUNT_POINT
"
]
&&
ZPOOL_MOUNT_POINT
=
"/
$ZPOOL
"
[
-z
"
$TOP_LEVEL_DATASET_MOUNTPOINT
"
]
&&
TOP_LEVEL_DATASET_MOUNTPOINT
=
"
${
ZPOOL_MOUNT_POINT
}
/
${
TOP_LEVEL_DATASET
}
"
[
-z
"
$TOP_LEVEL_DATASET_MOUNTPOINT
"
]
&&
TOP_LEVEL_DATASET_MOUNTPOINT
=
"
${
ZPOOL_MOUNT_POINT
}
/
${
TOP_LEVEL_DATASET
}
"
...
@@ -64,22 +78,64 @@ echo "zpool: $ZPOOL"
...
@@ -64,22 +78,64 @@ echo "zpool: $ZPOOL"
echo
" mounted on:
$ZPOOL_MOUNT_POINT
"
echo
" mounted on:
$ZPOOL_MOUNT_POINT
"
echo
"top-level dataset:
$TOP_LEVEL_DATASET
"
echo
"top-level dataset:
$TOP_LEVEL_DATASET
"
echo
" mounted on:
$TOP_LEVEL_DATASET_MOUNTPOINT
"
echo
" mounted on:
$TOP_LEVEL_DATASET_MOUNTPOINT
"
echo
""
echo
"This will unmount the HAF datasets, take a snapshot, then remount them."
check_dataset_is_unmountable
()
{
echo
-n
"Checking
$1
..."
if
lsof_result
=
$(
lsof +f
$1
)
;
then
echo
" error, dataset in use"
echo
"
$lsof_result
"
exit
1
fi
echo
" ok"
}
echo
"Verifying that all datasets are unmountable"
check_dataset_is_unmountable
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/haf_db_store/pgdata/pg_wal"
check_dataset_is_unmountable
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/haf_db_store/pgdata"
check_dataset_is_unmountable
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/haf_db_store/tablespace"
check_dataset_is_unmountable
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/haf_db_store/logs"
check_dataset_is_unmountable
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/blockchain"
check_dataset_is_unmountable
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
"
echo
"All datasets appear unmountable"
sync
;
sync
;
sync
sync
;
sync
;
sync
echo
3
>
/proc/sys/vm/drop_caches
echo
3
>
/proc/sys/vm/drop_caches
zfs umount
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/haf_db_store/pgdata/pg_wal"
unmount
()
{
zfs umount
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/haf_db_store/pgdata"
echo
-n
"Unmounting
$1
..."
zfs umount
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/haf_db_store/tablespace"
zfs umount
"
$1
"
zfs umount
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/haf_db_store/logs"
echo
" done"
zfs umount
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/blockchain"
}
zfs umount
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
"
unmount
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/haf_db_store/pgdata/pg_wal"
unmount
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/haf_db_store/pgdata"
unmount
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/haf_db_store/tablespace"
unmount
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/haf_db_store/logs"
unmount
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/blockchain"
unmount
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
"
echo
-n
"Taking snapshot..."
zfs snap
-r
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
@
${
SNAPSHOT_NAME
}
"
zfs snap
-r
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
@
${
SNAPSHOT_NAME
}
"
echo
" done"
remount
()
{
echo
-n
"Re-mounting
$1
..."
zfs umount
"
$1
"
echo
" done"
}
remount
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
"
remount
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/blockchain"
remount
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/haf_db_store/logs"
remount
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/haf_db_store/tablespace"
remount
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/haf_db_store/pgdata"
remount
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/haf_db_store/pgdata/pg_wal"
zfs
moun
t
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
"
zfs
lis
t
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
@
${
SNAPSHOT_NAME
}
"
\
zfs mount
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/blockchain
"
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/blockchain
@
${
SNAPSHOT_NAME
}
"
\
zfs mount
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/haf_db_store/logs
"
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/haf_db_store/logs
@
${
SNAPSHOT_NAME
}
"
\
zfs mount
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/haf_db_store/tablespace
"
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/haf_db_store/tablespace
@
${
SNAPSHOT_NAME
}
"
\
zfs mount
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/haf_db_store/pgdata
"
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/haf_db_store/pgdata
@
${
SNAPSHOT_NAME
}
"
\
zfs mount
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/haf_db_store/pgdata/pg_wal"
"
${
ZPOOL
}
/
${
TOP_LEVEL_DATASET
}
/haf_db_store/pgdata/pg_wal
@
${
SNAPSHOT_NAME
}
"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment