Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
computer:ubuntu:minisini_backup [2022/12/14 12:02] – angelegt springmcomputer:ubuntu:minisini_backup [2025/06/21 14:50] (current) – removed spring
Line 1: Line 1:
-====== Backup Linux-Rechner Lotte ====== +
-===== Backup-Script ===== +
-  #!/bin/bash +
-  basedir= +
-  user=lotte +
-  mediadir=/media/$user +
-  mountdir=/mnt/$user/autobackup +
-  mediaids=( +
- a134880c-d33e-4c70-8227-ea47e6341b1c +
-    de6ba9c3-cb24-41c0-aea8-a02be20ae30e +
-  ) +
-  sourcedirs2backup=( +
-    /home/lotte +
-    ) +
-   +
-  LOGFILE=/tmp/rsyncback.log +
-  LOG_MESSAGES=1 +
-   +
-  # -------------------------------------------------------- functions --- +
-  function message () { +
-    if [ ! -z $LOG_MESSAGES ]; then +
-        local msg=$1 +
-        echo `date +"%Y-%m-%d %H:%M:%S"` $msg +
-    fi +
-    echo `date +"%Y-%m-%d %H:%M:%S"` $msg 2>&1 >> $LOGFILE +
-  } +
-   +
-  # ------------------------------------------------------------- Main --- +
-  if [ ! -d $mediadir ]; then +
-    message "Error: Mediadir $mediadir does not exist. Exiting." +
-    exit 1 +
-  fi +
-   +
-  for mid in "${mediaids[@]}"; do +
-    echo mid $mid +
-    if [ -d $mediadir/$mid ]; then +
-        basedir=$mediadir/$mid +
-        device=$(mount | grep $mid | cut -d " " -f 1) +
-        if [ ! -z "$device" ]; then +
-            break  +
-        fi +
-    fi +
-  done +
-  if [ -z "$basedir" ]; then +
-    message "No configured media mounted. Exiting" +
-    exit 1 +
-  fi +
-  message "Medium mounted. Basedir: $basedir Device: $device" +
-   +
-  #lastdir=$(ls -tr $basedir| tail -1) +
-  lastdir=$(ls -1 $basedir | grep -v lost | tail -1) +
-  targetdir=$basedir/$(date +%Y-%m-%d)  +
-  if [ ! -d $targetdir ]; then +
-    message "performing backup to $targetdir" +
-    if [ ! -z "$lastdir" ] && [ -d "$basedir/$lastdir" ]; then +
-        message "copying $lastdir to $targetdir" +
-        nice cp -al $basedir/$lastdir $targetdir +
-    else +
-        message "no dir for copying found in $basedir" +
-    fi +
-    rsyncopts="-a -h --numeric-ids --relative --delete --delete-excluded --hard-links --stats" +
-    rsyncexcludes="--exclude .cache/ --exclude Trash/ --exclude datareporting/archived/ --exclude *msf" +
-    message "starting rsync" +
-    for sourcedir in "${sourcedirs2backup[@]}"; do +
-        nice rsync $rsyncopts $sourcedir $targetdir +
-    done +
-    message "backup on $basedir done"  +
-  else +
-    message "heute schon gebackupt"  +
-  fi +
-  mount -o ro,remount $device $basedir +
-   +
-  # Local variables: +
-  # compile-command: "bash /home/springm/projekte/lotte/rsyncback.sh" +
-  # End:+
  • computer/ubuntu/minisini_backup.1671019330.txt.gz
  • Last modified: 2022/12/14 12:02
  • by springm