#967 Issue closed: How to use customized folder instead of /tmp for temp file creation during system backup

Labels: support / question, fixed / solved / done

yin747 opened issue at 2016-08-17 02:06:

Relax-and-Recover (rear) Issue Template

Please fill in the following items before submitting a new issue:

  • rear version (/usr/sbin/rear -V): Relax-and-Recover 1.17.2 / Git
  • OS version (cat /etc/rear/os.conf or lsb_release -a): Red Hat Enterprise Linux Server release 7.2 (Maipo)
  • rear configuration files (cat /etc/rear/site.conf or cat /etc/rear/local.conf):
    NON-PROD[root@cdctst1r rear]$ cat /etc/rear/site.conf
    OUTPUT=ISO
    OUTPUT_URL=null
    BACKUP=NETFS
    BACKUP_URL=iso:///fsbackup/
    NETFS_KEEP_OLD_BACKUP_COPY=
    NON-PROD[root@cdctst1r rear]$ cat /etc/rear/local.conf
    BACKUP_PROG_EXCLUDE=("${BACKUP_PROG_EXCLUDE[@]}"
    '/dev' '/media' '/mnt' '/proc' '/sys' '/tmp' '/run' '/var/tmp' '/var/crash' '/fsbackup' '/linuxbackup' )
    EXCLUDE_RECREATE=( "${EXCLUDE_RECREATE[@]}"
    "fs:/proc/sys/fs/binfmt_misc" "fs:/sl_test" "fs:/seed_7" "fs:/fsbackup" )
  • Brief description of the issue
    No space left on device (/tmp) during backup. How to use customized folder instead of /tmp for temp file creation?

Log

2016-08-16 18:02:34 Creating tar archive '/tmp/rear.ruaw41MyKIqXXZ1/tmp/isofs/fsbackup//backup.tar.gz'
2016-08-16 18:03:45 WARNING: tar ended with return code 1 and below output:
---snip---
tar: Removing leading /' from member names tar: Removing leading/' from hard link targets


This means that files have been modified during the archiving
process. As a result the backup may not be completely consistent
or may not be a perfect copy of the system. Relax-and-Recover
will continue, however it is highly advisable to verify the
backup in order to be sure to safely recover this system.

2016-08-16 18:03:45 Archived 1352 MiB in 70 seconds [avg 19780 KiB/sec]
'/tmp/rear.ruaw41MyKIqXXZ1/tmp/backup.log' -> '/tmp/rear.ruaw41MyKIqXXZ1/tmp/isofs/fsbackup//backup.log'
cp: error writing '/tmp/rear.ruaw41MyKIqXXZ1/tmp/isofs/fsbackup//backup.log': No space left on device
cp: failed to extend '/tmp/rear.ruaw41MyKIqXXZ1/tmp/isofs/fsbackup//backup.log': No space left on device
2016-08-16 18:03:45 Including backup/NETFS/GNU/Linux/60_start_selinux.sh
2016-08-16 18:03:45 Including backup/NETFS/GNU/Linux/62_force_autorelabel.sh
2016-08-16 18:03:45 Including backup/NETFS/default/97_remove_lock.sh
removed '/tmp/rear.ruaw41MyKIqXXZ1/tmp/isofs/fsbackup//.lockfile'
2016-08-16 18:03:45 Including backup/NETFS/default/98_umount_NETFS_dir.sh
rmdir: removing directory, '/tmp/rear.ruaw41MyKIqXXZ1/outputfs'
2016-08-16 18:03:45 Finished running 'backup' stage in 71 seconds
2016-08-16 18:03:45 Running 'output' stage
2016-08-16 18:03:45 Including output/default/01_set_umask.sh
2016-08-16 18:03:45 Setting umask to 077
2016-08-16 18:03:45 Including output/default/10_mount_output_path.sh
mkdir: created directory '/tmp/rear.ruaw41MyKIqXXZ1/outputfs'
2016-08-16 18:03:45 Including output/default/15_save_copy_of_prefix_dir.sh
2016-08-16 18:03:45 Including output/default/20_make_boot_dir.sh
mkdir: cannot create directory '/tmp/rear.ruaw41MyKIqXXZ1/tmp/boot': No space left on device
2016-08-16 18:03:45 ERROR: Could not mkdir /tmp/rear.ruaw41MyKIqXXZ1/tmp/boot
=== Stack trace ===
Trace 0: /usr/sbin/rear:251 main
Trace 1: /usr/share/rear/lib/mkbackup-workflow.sh:22 WORKFLOW_mkbackup
Trace 2: /usr/share/rear/lib/framework-functions.sh:70 SourceStage
Trace 3: /usr/share/rear/lib/framework-functions.sh:31 Source
Trace 4: /usr/share/rear/output/default/20_make_boot_dir.sh:3 source
Trace 5: /usr/share/rear/lib/_input-output-functions.sh:132 StopIfError

Message: Could not mkdir /tmp/rear.ruaw41MyKIqXXZ1/tmp/boot

2016-08-16 18:03:45 Running exit tasks.
rmdir: removing directory, '/tmp/rear.ruaw41MyKIqXXZ1/outputfs'
2016-08-16 18:03:45 Finished in 94 seconds
2016-08-16 18:03:45 Removing build area /tmp/rear.ruaw41MyKIqXXZ1
rmdir: removing directory, '/tmp/rear.ruaw41MyKIqXXZ1'
2016-08-16 18:03:45 End of program reached

feichashao commented at 2016-08-17 07:01:

Can TMPDIR=/bigdisk help?

jsmeix commented at 2016-08-17 10:02:

The working directoy is created by this code in usr/sbin/rear

    # Create temporary work area and register removal exit task:
    BUILD_DIR="$( mktemp -d -t rear.XXXXXXXXXXXXXXX || Error ...
    ....
    Log "Using build area '$BUILD_DIR'"

and "man mktemp" reads

-t  interpret TEMPLATE as a single file name component,
    relative to a directory: $TMPDIR, if set; else the directory
    specified via -p; else /tmp

On my systems (SLES11 and SLES12) that just works:

# mktemp -d -t rear.XXXXXXXXXXXXXXX
/tmp/rear.m0IKWVnqgMiOIu8
# TMPDIR=/var/tmp/ mktemp -d -t rear.XXXXXXXXXXXXXXX
/var/tmp/rear.Bt146eGtAX53tB9

But that way it does not work for rear:

export TMPDIR=/var/tmp/ ; rear -d -D mkrescue

because in usr/share/rear/conf/default.conf there is

# the TMPDIR influences the mktemp command to define an alternative basedir instead of /tmp
# useful in case he /tmp is not large enough to contain ISO images and/or backup archives
# be careful the directory MUST exist otherwise you will get an error by mktemp
TMPDIR=""
export TMPDIR    # the export is required so that mktemp can pickup the variable

Bottom line:
For rear the solution is to read default.conf and act accordingly
as described in "man rear" ;-)

jsmeix commented at 2016-08-17 12:12:

The current behaviour that default.conf sets TMPDIR to empty value
looks like a bug to me: https://github.com/rear/rear/issues/968

jsmeix commented at 2016-08-17 13:07:

With https://github.com/rear/rear/pull/969 merged
rear should behave in compliance with Unix standards.

For example

TMPDIR="/var/tmp" rear -d -D mkrescue

is now using build area '/var/tmp/rear...'.

FYI:
In general regarding how to test the currently
newest rear GitHub master code:
Basically "git clone" it into a directory and
then run rear from within that directory.

# git clone https://github.com/rear/rear.git
# cd rear
# vi etc/rear/local.conf
# usr/sbin/rear -d -D mkbackup

[Export of Github issue for rear/rear.]