added backup disk and backup folder directory
This commit is contained in:
@@ -0,0 +1,43 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ "$(id -u)" != "0" ]; then
|
||||||
|
echo "You must be root"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
create_backup() {
|
||||||
|
disk=$1
|
||||||
|
archive=$2
|
||||||
|
dd if=$disk status=progress | gzip -9 > $archive
|
||||||
|
}
|
||||||
|
|
||||||
|
restore_backup() {
|
||||||
|
archive=$1
|
||||||
|
disk=$2
|
||||||
|
gzip -dc $archive | dd of=$disk status=progress
|
||||||
|
}
|
||||||
|
|
||||||
|
print_help() {
|
||||||
|
printf "usage:\n\t$0 (create|restore)\nexample:\n\t$0 create (disk) (archive)\n\t$0 restore (archive) (disk)\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
"create")
|
||||||
|
if [[ "$2" == "" || "$3" == "" ]]; then
|
||||||
|
print_help
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
create_backup $2 $3
|
||||||
|
;;
|
||||||
|
"restore")
|
||||||
|
if [[ "$2" == "" || "$3" == "" ]]; then
|
||||||
|
print_help
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
restore_backup $2 $3
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
print_help
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
Executable
+42
@@ -0,0 +1,42 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ "$(id -u)" != "0" ]; then
|
||||||
|
echo "You must be root"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
create_backup() {
|
||||||
|
directory=$1
|
||||||
|
filename=$2
|
||||||
|
mksquashfs $directory $filename
|
||||||
|
}
|
||||||
|
|
||||||
|
restore_backup() {
|
||||||
|
filename=$1
|
||||||
|
directory=$2
|
||||||
|
unsquashfs -f -d $directory $filename
|
||||||
|
}
|
||||||
|
|
||||||
|
print_help() {
|
||||||
|
printf "usage:\n\t$0 (create|restore)\nexample:\n\t$0 create (folder|directory) (filename)\n\t$0 restore (filename) (folder|directory)\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
"create")
|
||||||
|
if [[ "$2" == "" || "$3" == "" ]]; then
|
||||||
|
print_help
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
create_backup $2 $3
|
||||||
|
;;
|
||||||
|
"restore")
|
||||||
|
if [[ "$2" == "" || "$3" == "" ]]; then
|
||||||
|
print_help
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
restore_backup $2 $3
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
print_help
|
||||||
|
;;
|
||||||
|
esac
|
||||||
Reference in New Issue
Block a user