Compare commits
3 Commits
96893dff23
...
f23a40f524
Author | SHA1 | Date | |
---|---|---|---|
f23a40f524 | |||
7b1d0ef251 | |||
36e122b62c |
@ -186,26 +186,29 @@ colours() {
|
||||
|
||||
# ex - archive extractor
|
||||
# usage: ex <file>
|
||||
ex ()
|
||||
{
|
||||
if [ -f $1 ] ; then
|
||||
case $1 in
|
||||
*.tar.bz2) tar xjf $1 ;;
|
||||
*.tar.gz) tar xzf $1 ;;
|
||||
*.bz2) bunzip2 $1 ;;
|
||||
*.rar) unrar x $1 ;;
|
||||
*.gz) gunzip $1 ;;
|
||||
*.tar) tar xf $1 ;;
|
||||
*.tbz2) tar xjf $1 ;;
|
||||
*.tgz) tar xzf $1 ;;
|
||||
*.zip) unzip $1 ;;
|
||||
*.Z) uncompress $1;;
|
||||
*.7z) 7z x $1 ;;
|
||||
*) echo "'$1' cannot be extracted via ex()" ;;
|
||||
esac
|
||||
else
|
||||
ex() {
|
||||
if [[ ! -f "$1" ]]; then
|
||||
echo "'$1' is not a valid file"
|
||||
return 1;
|
||||
fi
|
||||
# FIXME 7z kann (theoretisch) tar
|
||||
outdir=${1%.*}
|
||||
case "$1" in
|
||||
*.tar.bz2 | *.tbz | *.tbz2)
|
||||
tar xjf $1 -C $outdir;;
|
||||
*.tar.gz | *.tgz)
|
||||
tar xzf $1 -C $outdir;;
|
||||
*.tar)
|
||||
tar xf $1 -C $outdir;;
|
||||
*.7z | *.zip | *.gz | *.bz | *.bz2)
|
||||
7z x -o$outdir $1;;
|
||||
*.rar)
|
||||
unrar x $1;;
|
||||
*.Z)
|
||||
uncompress $1;;
|
||||
*)
|
||||
echo "'$1' cannot be extracted via ex()";;
|
||||
esac
|
||||
}
|
||||
|
||||
# BEGIN_KITTY_SHELL_INTEGRATION
|
||||
|
@ -10,20 +10,47 @@ shopt -s expand_aliases # make aliases work
|
||||
###############################
|
||||
|
||||
BACKUP_DIR=/sync/backup
|
||||
ensureDirectory $BACKUP_DIR
|
||||
BACKUP_DIR_HOME=$BACKUP_DIR/home
|
||||
rsync_backup $HOME/.ssh/ $BACKUP_DIR_HOME/.ssh/
|
||||
ensureDirectory $BACKUP_DIR_HOME
|
||||
backupDirectory $HOME/.ssh/ $BACKUP_DIR_HOME/.ssh/
|
||||
|
||||
BACKUP_DIR_ROOT=$BACKUP_DIR/root/etc
|
||||
sd rsync_backup /etc/ddclient/ $BACKUP_DIR_ROOT/ddclient/
|
||||
sd rsync_backup /etc/ddclient.conf $BACKUP_DIR_ROOT/
|
||||
sd rsync_backup /etc/letsencrypt/ $BACKUP_DIR_ROOT/letsencrypt/
|
||||
sd rsync_backup /etc/nginx/ $BACKUP_DIR_ROOT/nginx/
|
||||
sd rsync_backup /etc/ssh/ $BACKUP_DIR_ROOT/ssh/
|
||||
sd rsync_backup /etc/wireguard/ $BACKUP_DIR_ROOT/wireguard/
|
||||
ensureRootDirectory $BACKUP_DIR_ROOT
|
||||
sd rsync_backup /etc/hosts $BACKUP_DIR_ROOT/
|
||||
sd rsync_backup /etc/docker/daemon.json $BACKUP_DIR_ROOT/docker/
|
||||
sd rsync_backup /etc/ddclient.conf $BACKUP_DIR_ROOT/
|
||||
backupRootDirectory /etc/ddclient/ $BACKUP_DIR_ROOT/ddclient/
|
||||
backupRootDirectory /etc/letsencrypt/ $BACKUP_DIR_ROOT/letsencrypt/
|
||||
backupRootDirectory /etc/nginx/ $BACKUP_DIR_ROOT/nginx/
|
||||
backupRootDirectory /etc/ssh/ $BACKUP_DIR_ROOT/ssh/
|
||||
backupRootDirectory /etc/wireguard/ $BACKUP_DIR_ROOT/wireguard/
|
||||
backupRootDirectory /etc/docker/daemon.json $BACKUP_DIR_ROOT/docker/
|
||||
|
||||
|
||||
backupRootDirectory() {
|
||||
ensureRootDirectory $2
|
||||
sd rsync_backup $1 $2
|
||||
}
|
||||
|
||||
|
||||
backupDirectory() {
|
||||
ensureDirectory $2
|
||||
rsync_backup $1 $2
|
||||
}
|
||||
|
||||
|
||||
ensureRootDirectory() {
|
||||
ensureDirectory $1
|
||||
sudo chown root:root $1
|
||||
}
|
||||
|
||||
|
||||
ensureDirectory() {
|
||||
if [[ ! -e $1 ]]; then
|
||||
mkdir -p $1
|
||||
fi
|
||||
}
|
||||
|
||||
#####################
|
||||
### upload backup ###
|
||||
#####################
|
||||
|
Loading…
Reference in New Issue
Block a user