mirror of
https://github.com/octoleo/hosts.git
synced 2024-11-24 13:47:35 +00:00
Use alpha ordering for subcommand handling in backup
.
This commit is contained in:
parent
5c87ad62b0
commit
5049abe817
24
hosts
24
hosts
@ -610,16 +610,16 @@ add() {
|
|||||||
desc "backups" <<HEREDOC
|
desc "backups" <<HEREDOC
|
||||||
Usage:
|
Usage:
|
||||||
${_ME} backups
|
${_ME} backups
|
||||||
${_ME} backups create
|
|
||||||
${_ME} backups compare <filename>
|
${_ME} backups compare <filename>
|
||||||
|
${_ME} backups create
|
||||||
${_ME} backups delete <filename>
|
${_ME} backups delete <filename>
|
||||||
${_ME} backups restore <filename> [--skip-backup]
|
${_ME} backups restore <filename> [--skip-backup]
|
||||||
${_ME} backups show <filename>
|
${_ME} backups show <filename>
|
||||||
|
|
||||||
Subcommands:
|
Subcommands:
|
||||||
backups List available backups.
|
backups List available backups.
|
||||||
backups create Create a new backup of the hosts file.
|
|
||||||
backups compare Compare a backup file with the current hosts file.
|
backups compare Compare a backup file with the current hosts file.
|
||||||
|
backups create Create a new backup of the hosts file.
|
||||||
backups delete Delete the specified backup.
|
backups delete Delete the specified backup.
|
||||||
backups restore Replace the contents of the hosts file with a
|
backups restore Replace the contents of the hosts file with a
|
||||||
specified backup. The hosts file is automatically
|
specified backup. The hosts file is automatically
|
||||||
@ -647,7 +647,7 @@ backups() {
|
|||||||
--skip-backup)
|
--skip-backup)
|
||||||
_skip_backup=1
|
_skip_backup=1
|
||||||
;;
|
;;
|
||||||
create|compare|delete|restore|show)
|
compare|create|delete|restore|show)
|
||||||
_subcommand="${__arg}"
|
_subcommand="${__arg}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@ -660,15 +660,6 @@ backups() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
case "${_subcommand}" in
|
case "${_subcommand}" in
|
||||||
create)
|
|
||||||
_verify_write_permissions
|
|
||||||
|
|
||||||
local _timestamp
|
|
||||||
_timestamp="$(date +"%Y%m%d%H%M%S")"
|
|
||||||
|
|
||||||
cp "${HOSTS_PATH}" "${HOSTS_PATH}--backup-${_timestamp}" && \
|
|
||||||
printf "Backed up to %s--backup-%s\\n" "${HOSTS_PATH}" "${_timestamp}"
|
|
||||||
;;
|
|
||||||
compare)
|
compare)
|
||||||
if [[ -z "${_filename:-}" ]]
|
if [[ -z "${_filename:-}" ]]
|
||||||
then
|
then
|
||||||
@ -681,6 +672,15 @@ backups() {
|
|||||||
|
|
||||||
diff -u "${HOSTS_PATH}" "${_hosts_dirname}/${_filename}"
|
diff -u "${HOSTS_PATH}" "${_hosts_dirname}/${_filename}"
|
||||||
;;
|
;;
|
||||||
|
create)
|
||||||
|
_verify_write_permissions
|
||||||
|
|
||||||
|
local _timestamp
|
||||||
|
_timestamp="$(date +"%Y%m%d%H%M%S")"
|
||||||
|
|
||||||
|
cp "${HOSTS_PATH}" "${HOSTS_PATH}--backup-${_timestamp}" && \
|
||||||
|
printf "Backed up to %s--backup-%s\\n" "${HOSTS_PATH}" "${_timestamp}"
|
||||||
|
;;
|
||||||
delete)
|
delete)
|
||||||
if [[ -z "${_filename:-}" ]]
|
if [[ -z "${_filename:-}" ]]
|
||||||
then
|
then
|
||||||
|
Loading…
Reference in New Issue
Block a user