Script for filesystem back up troubles.

This forum is dedicated to advanced help and support :

Ask here your questions about advanced usage of Mageia. For example you may post here all your questions about network and automated installs, complex server configurations, kernel tuning, creating your own Mageia mirrors, and all tasks likely to be touchy even for skilled users.

Script for filesystem back up troubles.

Postby xboxboy » Jul 22nd, '17, 15:10

While I have basic data backup happening, I want to move to towards keeping my systems backed up also.

So using this as a template: https://forums.mageia.org/en/viewtopic.php?f=41&t=5957

I've come up with

Code: Select all
#! /bin/sh

#lifesaving backup mechanism from Mageia.org

#Used to back up filesystem prior to updating


rm -rf /srv/exthdd/fsback/backup6
mv /srv/exthdd/fsback/backup5 /srv/exthdd/fsback/backup6
mv /srv/exthdd/fsback/backup4 /srv/exthdd/fsback/backup5
mv /srv/exthdd/fsback/backup3 /srv/exthdd/fsback/backup4
mv /srv/exthdd/fsback/backup2 /srv/exthdd/fsback/backup3
mv /srv/exthdd/fsback/backup1 /srv/exthdd/fsback/backup2
cp -al /srv/exthdd/fsback/backup0 /srv/exthdd/fsback/backup1
rsync -av --delete --exclude /dev --exclude /tmp --exclude /home --exclude /media --exclude /proc --exclude /sys --exclude /mnt --exclude /var/tmp  --exclude /var/cache --exclude /srv/exthdd --exclude /srv/owncloud / /srv/exthdd/fsback/backup0



Trouble is I've over complicated the file system/mountings.

This is actually a raspberry pi system (not magiea at this point, but fedora).
I originally had the /boot and / partitions on the sd card as usual, but then added an external HDD mounted at /srv/exthdd for the owncloud/nextcloud data directory.

I've since moved / to the hdd on another partition as well, so

Code: Select all
@localhost ~]$ mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=388524k,nr_inodes=97131,mode=755)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,seclabel,mode=755)
cgroup on /sys/fs/cgroup/unified type cgroup2 (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime,seclabel)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
configfs on /sys/kernel/config type configfs (rw,relatime)
/dev/sda1 on / type ext4 (rw,noatime,seclabel,data=ordered)
selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=39,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=13694)
debugfs on /sys/kernel/debug type debugfs (rw,relatime,seclabel)
mqueue on /dev/mqueue type mqueue (rw,relatime,seclabel)
/dev/mmcblk0p2 on /boot type ext3 (rw,noatime,seclabel,data=ordered)
/dev/sda3 on /srv/exthdd type ext4 (rw,relatime,seclabel,data=ordered)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=99264k,mode=700,uid=1000,gid=1000)
tmpfs on /run/user/0 type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=99264k,mode=700)
/dev/mmcblk0p4 on /run/media/username/__ type ext4 (rw,nosuid,nodev,relatime,seclabel,data=ordered,uhelper=udisks2)


So in /srv are two directories, one is simply for owncloud, which then links back to /srv/exthdd/owncloud/data, from when I first added the hdd to the system.

Code: Select all
ls -al /srv
total 16
drwxr-xr-x.  4 root   root   4096 Feb 11 03:07 .
dr-xr-xr-x. 19 root   root   4096 Jul 26  2016 ..
drwxr-xr-x.  7 root   root   4096 Jul 22 20:58 exthdd
drwxr-xr-x.  2 apache apache 4096 Oct  3  2016 owncloud
[root@localhost /]# cd /srv/owncloud/
[root@localhost owncloud]# ls -al
total 8
drwxr-xr-x. 2 apache apache 4096 Oct  3  2016 .
drwxr-xr-x. 4 root   root   4096 Feb 11 03:07 ..
lrwxrwxrwx. 1 apache apache   25 Oct  3  2016 data -> /srv/exthdd/owncloud/data


Now my issue is, when I test run the rsync line from the backup script

Code: Select all
rsync -av --delete --exclude /dev --exclude /tmp --exclude /home --exclude /media --exclude /proc --exclude /sys --exclude /mnt --exclude /var/tmp  --exclude /var/cache --exclude /srv/exthdd --exclude /srv/owncloud / /srv/exthdd/fsback/backup0


It includes /srv and all it holds, which makes the backup hugely slow and massive.

What am I doing wrong or missed out? All help appreciated.
xboxboy
 
Posts: 400
Joined: Jun 2nd, '13, 06:41

Re: Script for filesystem back up troubles.

Postby xboxboy » Jul 22nd, '17, 16:40

Wow, wasn't that fun :?

So, the original / partition on the sd card was being auto mounted, and of course my script was picking that up at /run/media/username/__ and then grabbing the links from there

So I was able to edit fstab to add 'noauto' to the line for the / partition on the sd card, and that appears to have stopped it. I'll test it for a few updates, then report back.
xboxboy
 
Posts: 400
Joined: Jun 2nd, '13, 06:41


Return to Advanced support

Who is online

Users browsing this forum: No registered users and 1 guest