Compare commits
2 Commits
e37268fd88
...
4cd270ac54
Author | SHA1 | Date | |
---|---|---|---|
4cd270ac54 | |||
553d15e38b |
@ -1,34 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
source /sync/home_external/.bash_aliases
|
source /sync/scripts/backup_resources.sh
|
||||||
|
# FSFIXME expand_aliases still needed?
|
||||||
shopt -s expand_aliases # make aliases work
|
shopt -s expand_aliases # make aliases work
|
||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
###############################
|
###############################
|
||||||
### update local backup dir ###
|
### update local backup dir ###
|
||||||
###############################
|
###############################
|
||||||
@ -37,10 +13,12 @@ BACKUP_DIR=/sync/backup
|
|||||||
ensureDirectory $BACKUP_DIR
|
ensureDirectory $BACKUP_DIR
|
||||||
BACKUP_DIR_HOME=$BACKUP_DIR/home
|
BACKUP_DIR_HOME=$BACKUP_DIR/home
|
||||||
ensureDirectory $BACKUP_DIR_HOME
|
ensureDirectory $BACKUP_DIR_HOME
|
||||||
|
|
||||||
backupDirectory $HOME/.ssh/ $BACKUP_DIR_HOME/.ssh/
|
backupDirectory $HOME/.ssh/ $BACKUP_DIR_HOME/.ssh/
|
||||||
|
|
||||||
BACKUP_DIR_ROOT=$BACKUP_DIR/root/etc
|
BACKUP_DIR_ROOT=$BACKUP_DIR/root/etc
|
||||||
ensureRootDirectory $BACKUP_DIR_ROOT
|
ensureRootDirectory $BACKUP_DIR_ROOT
|
||||||
|
|
||||||
sd rsync_backup /etc/hosts $BACKUP_DIR_ROOT/
|
sd rsync_backup /etc/hosts $BACKUP_DIR_ROOT/
|
||||||
sd rsync_backup /etc/ddclient.conf $BACKUP_DIR_ROOT/
|
sd rsync_backup /etc/ddclient.conf $BACKUP_DIR_ROOT/
|
||||||
backupRootDirectory /etc/ddclient/ $BACKUP_DIR_ROOT/ddclient/
|
backupRootDirectory /etc/ddclient/ $BACKUP_DIR_ROOT/ddclient/
|
||||||
@ -60,3 +38,4 @@ fi
|
|||||||
|
|
||||||
sd rsync_backup -e "ssh -i /home/edi/.ssh/id_ed25519" --filter="P /home/docker" /sync/backup/ fabian@garrus:/citadel/backup/edi/
|
sd rsync_backup -e "ssh -i /home/edi/.ssh/id_ed25519" --filter="P /home/docker" /sync/backup/ fabian@garrus:/citadel/backup/edi/
|
||||||
sd rsync_backup -e "ssh -i /home/edi/.ssh/id_ed25519" /home/edi/docker/ fabian@garrus:/citadel/backup/edi/home/docker/
|
sd rsync_backup -e "ssh -i /home/edi/.ssh/id_ed25519" /home/edi/docker/ fabian@garrus:/citadel/backup/edi/home/docker/
|
||||||
|
echo "Note: remember to keep /citadel in sync!"
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
source /sync/home_external/.bash_aliases
|
source /sync/scripts/backup_resources.sh
|
||||||
|
# FSFIXME expand_aliases still needed?
|
||||||
shopt -s expand_aliases # make aliases work
|
shopt -s expand_aliases # make aliases work
|
||||||
|
|
||||||
|
|
||||||
###############################
|
###############################
|
||||||
### update local backup dir ###
|
### update local backup dir ###
|
||||||
###############################
|
###############################
|
||||||
|
|
||||||
BACKUP_DIR=/sync/backup
|
BACKUP_DIR=/sync/backup
|
||||||
|
ensureDirectory $BACKUP_DIR
|
||||||
BACKUP_DIR_HOME=$BACKUP_DIR/home
|
BACKUP_DIR_HOME=$BACKUP_DIR/home
|
||||||
if [[ !($HOME/.bash_aliases_local -ef $BACKUP_DIR_HOME/.bash_aliases_local) ]]; then
|
ensureDirectory $BACKUP_DIR_HOME
|
||||||
ln $HOME/.bash_aliases_local $BACKUP_DIR_HOME/.bash_aliases_local
|
|
||||||
fi
|
|
||||||
|
|
||||||
BACKUP_DIR_ROOT=$BACKUP_DIR/root/etc
|
BACKUP_DIR_ROOT=$BACKUP_DIR/root/etc
|
||||||
rsync_backup --link-dest="/etc/ssh/" /etc/ssh/ $BACKUP_DIR_ROOT/ssh/
|
ensureRootDirectory $BACKUP_DIR_ROOT
|
||||||
|
backupRootDirectory /etc/ssh/ $BACKUP_DIR_ROOT/ssh/
|
||||||
if [[ !(-d $BACKUP_DIR_ROOT/udev/rules.d) ]]; then
|
if [[ !(-d $BACKUP_DIR_ROOT/udev/rules.d) ]]; then
|
||||||
mkdir $BACKUP_DIR_ROOT/udev/rules.d
|
mkdir $BACKUP_DIR_ROOT/udev/rules.d
|
||||||
fi
|
fi
|
||||||
@ -24,6 +24,7 @@ if [[ !(/etc/udev/rules.d/69-hdparm.rules -ef $BACKUP_DIR_ROOT/udev/rules.d/69-h
|
|||||||
ln /etc/udev/rules.d/69-hdparm.rules $BACKUP_DIR_ROOT/udev/rules.d/69-hdparm.rules
|
ln /etc/udev/rules.d/69-hdparm.rules $BACKUP_DIR_ROOT/udev/rules.d/69-hdparm.rules
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
backupRootDirectory /etc/ssh/ $BACKUP_DIR_ROOT/ssh/
|
||||||
|
|
||||||
#####################
|
#####################
|
||||||
### upload backup ###
|
### upload backup ###
|
||||||
|
30
scripts/backup_resources.sh
Normal file
30
scripts/backup_resources.sh
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
source /sync/home_external/.bash_aliases
|
||||||
|
shopt -s expand_aliases # make aliases work
|
||||||
|
|
||||||
|
|
||||||
|
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 [[ ! -d $1 ]]; then
|
||||||
|
mkdir -p $1
|
||||||
|
fi
|
||||||
|
}
|
@ -1,24 +1,27 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
source /sync/home_external/.bash_aliases
|
source /sync/scripts/backup_resources.sh
|
||||||
|
# FSFIXME expand_aliases still needed?
|
||||||
shopt -s expand_aliases # make aliases work
|
shopt -s expand_aliases # make aliases work
|
||||||
|
|
||||||
|
|
||||||
###############################
|
###############################
|
||||||
### update local backup dir ###
|
### update local backup dir ###
|
||||||
###############################
|
###############################
|
||||||
|
|
||||||
BACKUP_DIR=/sync/backup
|
BACKUP_DIR=/sync/backup
|
||||||
|
ensureDirectory $BACKUP_DIR
|
||||||
BACKUP_DIR_HOME=$BACKUP_DIR/home
|
BACKUP_DIR_HOME=$BACKUP_DIR/home
|
||||||
if [[ !($HOME/.bash_aliases_local -ef $BACKUP_DIR_HOME/.bash_aliases_local) ]]; then
|
ensureDirectory $BACKUP_DIR_HOME
|
||||||
ln $HOME/.bash_aliases_local $BACKUP_DIR_HOME/.bash_aliases_local
|
|
||||||
fi
|
|
||||||
rsync_backup --link-dest="$HOME/.ssh/" $HOME/.ssh/ $BACKUP_DIR_HOME/.ssh/
|
|
||||||
|
|
||||||
|
backupDirectory $HOME/.ssh/ $BACKUP_DIR_HOME/.ssh/
|
||||||
|
|
||||||
#####################
|
#####################
|
||||||
### upload backup ###
|
### upload backup ###
|
||||||
#####################
|
#####################
|
||||||
|
|
||||||
|
if [[ "$1" == "--noupload" ]]; then
|
||||||
|
exit 0;
|
||||||
|
fi
|
||||||
|
|
||||||
sd rsync_backup -e "ssh -i /home/fabian/.ssh/id_ed25519" $BACKUP_DIR/ fabian@garrus:/citadel/backup/shepard/
|
sd rsync_backup -e "ssh -i /home/fabian/.ssh/id_ed25519" $BACKUP_DIR/ fabian@garrus:/citadel/backup/shepard/
|
||||||
|
Loading…
Reference in New Issue
Block a user