rdiff-backup fatal errors, relevant increments found? - linux

I'm running rdiff-backup to backup some folders on a remote system.
rdiff-backup root#<REMOTESERVER>::/apps/myapp/shared/system /home/backups/system
echo "$(date): Completed... removing backup data older than 4 weeks"
rdiff-backup --remove-older-than 4W /home/backups/system
echo "$(date): Completed..."
Running this leads to errors though during the --remove-older-than command:
Fatal Error: Found 81 relevant increments, dated:
Wed Aug 29 00:41:47 2012
Thu Aug 30 00:57:49 2012
Fri Aug 31 01:04:03 2012
Sat Sep 1 00:44:59 2012
Sun Sep 2 00:41:49 2012
Mon Sep 3 00:41:39 2012
If you want to delete multiple increments in this way, use the --force.
So yeah, I can probably just put --force on it, but I'd like to understand what's going on here and haven't been able to find much on this problem.
Any ideas?

It's just rdiff-backup making sure you really mean it. The usual workflow for --remove-older-than is to run regularly, removing just the oldest increment. In order to avoid data-loss, rdiff-backup requires you to be really sure before letting you remove multiple increments at once.

Related

How can I customise an ISO image of Webconverger with a Linux shell script?

I want to write a simple shell script that downloads the latest ISO image of Webconverger and changes the boot parameters of grub in /boot/live.cfg.
So this is what I have done so far:
#!/bin/bash
# 1. Download the ISO
wget https://build.webconverger.com/latest.iso
# 2. Mount the ISO and create a development folder
sudo mkdir /mnt/webconverger
sudo mount -o loop latest.iso /mnt/webconverger
mkdir devfolder
rsync -av /mnt/webconverger/ devfolder/
sudo umount /mnt/webconverger
sudo rm -r /mnt/webconverger
# 3. Change the file in the development folder.
chmod -R 777 devfolder/
rm devfolder/boot/live.cfg
echo \
"DEFAULT de
label de
menu label Start
kernel /live/vmlinuz
append initrd=/live/initrd.img boot=live skipconfig quiet splash components=gitfs net.ifnames=0 bootfrom=removable locale=de xkb=-layout%20de homepage=https://www.google.de/" \
> devfolder/boot/live.cfg
# 4. Create a new ISO image
mkisofs -o new.iso -l devfolder
rm -r devfolder/
The generated ISO does not boot.
I asume the reasons for the problem are, that I had to run the whole script with root privileges and that I need a more complex mkisofs command.
Does anybody know how to generate a proper ISO image for Webconverger with a shell script? Or is there an alternative method for the whole process? Something like ISO Master but for the command line?
Update
I have replaced the code snippets with the actual shell script. So it is easier to test. And here is the command line output (without the wget part):
mount: /dev/loop0 is write-protected, mounting read-only
sending incremental file list
./
boot/
boot/boot.bin
boot/boot.cat
boot/live.cfg
boot/syslinux/
boot/syslinux/ldlinux.c32
boot/syslinux/libcom32.c32
boot/syslinux/libutil.c32
boot/syslinux/splash.png
boot/syslinux/syslinux.cfg
boot/syslinux/vesainfo.c32
boot/syslinux/vesamenu.c32
live/
live/initrd.img
live/vmlinuz
live/filesystem.git/
live/filesystem.git/HEAD
live/filesystem.git/config
live/filesystem.git/description
live/filesystem.git/packed-refs
live/filesystem.git/shallow
live/filesystem.git/branches/
live/filesystem.git/hooks/
live/filesystem.git/hooks/applypatch-msg.sample
live/filesystem.git/hooks/commit-msg.sample
live/filesystem.git/hooks/post-update.sample
live/filesystem.git/hooks/pre-applypatch.sample
live/filesystem.git/hooks/pre-commit.sample
live/filesystem.git/hooks/pre-push.sample
live/filesystem.git/hooks/pre-rebase.sample
live/filesystem.git/hooks/pre-receive.sample
live/filesystem.git/hooks/prepare-commit-msg.sample
live/filesystem.git/hooks/update.sample
live/filesystem.git/info/
live/filesystem.git/info/exclude
live/filesystem.git/objects/
live/filesystem.git/objects/info/
live/filesystem.git/objects/pack/
live/filesystem.git/objects/pack/pack-1aa978c13266848f4644754d1875dc90ec4bfcdb.idx
live/filesystem.git/objects/pack/pack-1aa978c13266848f4644754d1875dc90ec4bfcdb.pack
live/filesystem.git/refs/
live/filesystem.git/refs/heads/
live/filesystem.git/refs/heads/master
live/filesystem.git/refs/remotes/
live/filesystem.git/refs/remotes/origin/
live/filesystem.git/refs/remotes/origin/HEAD
live/filesystem.git/refs/tags/
live/filesystem.git/refs/tags/initial-revision
sent 598,528,659 bytes received 726 bytes 239,411,754.00 bytes/sec
total size is 598,380,033 speedup is 1.00
I: -input-charset not specified, using utf-8 (detected in locale settings)
1.71% done, estimate finish Tue Jul 10 20:12:54 2018
3.42% done, estimate finish Tue Jul 10 20:12:54 2018
5.13% done, estimate finish Tue Jul 10 20:13:13 2018
6.84% done, estimate finish Tue Jul 10 20:13:08 2018
8.55% done, estimate finish Tue Jul 10 20:13:05 2018
10.26% done, estimate finish Tue Jul 10 20:13:03 2018
11.97% done, estimate finish Tue Jul 10 20:13:02 2018
13.68% done, estimate finish Tue Jul 10 20:13:01 2018
15.39% done, estimate finish Tue Jul 10 20:13:00 2018
17.10% done, estimate finish Tue Jul 10 20:12:59 2018
18.81% done, estimate finish Tue Jul 10 20:12:59 2018
20.52% done, estimate finish Tue Jul 10 20:12:58 2018
22.23% done, estimate finish Tue Jul 10 20:12:58 2018
23.94% done, estimate finish Tue Jul 10 20:12:58 2018
25.65% done, estimate finish Tue Jul 10 20:12:57 2018
27.36% done, estimate finish Tue Jul 10 20:12:57 2018
29.07% done, estimate finish Tue Jul 10 20:12:57 2018
30.78% done, estimate finish Tue Jul 10 20:12:57 2018
32.49% done, estimate finish Tue Jul 10 20:12:57 2018
34.20% done, estimate finish Tue Jul 10 20:12:56 2018
35.91% done, estimate finish Tue Jul 10 20:12:56 2018
37.62% done, estimate finish Tue Jul 10 20:12:56 2018
39.33% done, estimate finish Tue Jul 10 20:12:56 2018
41.04% done, estimate finish Tue Jul 10 20:12:56 2018
42.75% done, estimate finish Tue Jul 10 20:12:56 2018
44.46% done, estimate finish Tue Jul 10 20:12:56 2018
46.17% done, estimate finish Tue Jul 10 20:12:56 2018
47.88% done, estimate finish Tue Jul 10 20:12:56 2018
49.59% done, estimate finish Tue Jul 10 20:12:56 2018
51.30% done, estimate finish Tue Jul 10 20:12:55 2018
53.02% done, estimate finish Tue Jul 10 20:12:55 2018
54.72% done, estimate finish Tue Jul 10 20:12:55 2018
56.44% done, estimate finish Tue Jul 10 20:12:55 2018
58.14% done, estimate finish Tue Jul 10 20:12:55 2018
59.86% done, estimate finish Tue Jul 10 20:12:55 2018
61.56% done, estimate finish Tue Jul 10 20:12:55 2018
63.28% done, estimate finish Tue Jul 10 20:12:55 2018
64.98% done, estimate finish Tue Jul 10 20:12:55 2018
66.70% done, estimate finish Tue Jul 10 20:12:55 2018
68.40% done, estimate finish Tue Jul 10 20:12:55 2018
70.12% done, estimate finish Tue Jul 10 20:12:55 2018
71.82% done, estimate finish Tue Jul 10 20:12:55 2018
73.54% done, estimate finish Tue Jul 10 20:12:55 2018
75.24% done, estimate finish Tue Jul 10 20:12:55 2018
76.96% done, estimate finish Tue Jul 10 20:12:55 2018
78.66% done, estimate finish Tue Jul 10 20:12:55 2018
80.38% done, estimate finish Tue Jul 10 20:12:55 2018
82.08% done, estimate finish Tue Jul 10 20:12:55 2018
83.80% done, estimate finish Tue Jul 10 20:12:55 2018
85.50% done, estimate finish Tue Jul 10 20:12:55 2018
87.22% done, estimate finish Tue Jul 10 20:12:55 2018
88.92% done, estimate finish Tue Jul 10 20:12:55 2018
90.64% done, estimate finish Tue Jul 10 20:12:55 2018
92.34% done, estimate finish Tue Jul 10 20:12:55 2018
94.06% done, estimate finish Tue Jul 10 20:12:55 2018
95.76% done, estimate finish Tue Jul 10 20:12:55 2018
97.48% done, estimate finish Tue Jul 10 20:12:55 2018
99.18% done, estimate finish Tue Jul 10 20:12:55 2018
Total translation table size: 0
Total rockridge attributes bytes: 0
Total directory bytes: 30720
Path table size(bytes): 222
Max brk space used 2b000
292387 extents written (571 MB)
And this what I get in VirtualBox:
Click here!
So the full answer to the question is:
#!/bin/bash
# 1. Download the ISO
wget https://build.webconverger.com/latest.iso
# 2. Mount the ISO and create a development folder
sudo mkdir /mnt/webconverger
sudo mount -o loop latest.iso /mnt/webconverger
mkdir devfolder
rsync -av /mnt/webconverger/ devfolder/
sudo umount /mnt/webconverger
sudo rm -r /mnt/webconverger
# 3. Change the file in the development folder.
echo \
"DEFAULT de
label de
menu label Start
kernel /live/vmlinuz
append initrd=/live/initrd.img boot=live skipconfig quiet splash components=gitfs net.ifnames=0 bootfrom=removable locale=de xkb=-layout%20de homepage=https://duckduckgo.com nobrand" \
| sudo tee devfolder/boot/live.cfg
# 4. Create a new ISO image
sudo mkisofs -r -J -l -V "Webconverger" -b boot/boot.bin -c boot/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o new.iso devfolder
sudo isohybrid new.iso
sudo rm -r devfolder/
For some reason dd did not work for Webconverger images. Even the with the untouched latest.iso it was not possible to create a bootable USB flash drive. So I used Win32DiskImager.
What you want to do is to generate an El Torito bootable CD with an MBR in its first bytes.
mkisofs(8) needs some special options to create an "El Torito" bootable CD:
mkisofs -r -J -l -V "Webconverger" -b boot/boot.bin -c boot/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o new.iso devfolder
Explaination:
-r -J: Enable Joliet and Rock Ridge meta data.
-l: Allow long filenames.
-V: Set volume ID. Optional.
-b: Specify the "El Torito" boot image.
-c: Specify the "El Torito" boot catalog.
-no-emul-boot: Specify that this is an "El Torito" bootable CD.
-boot-load-size: number of 512 bytes sector to load (4 is what usually works)
-boot-info-table: modify the original boot image appending the Boot Info Table
Then, if you want to be able to just dd the file on a USB drive you will need to write an MBR onto the ISO:
isohybrid new.iso

Want to show create time for some files.

I was writing perl and run it in window system pretty good .
But when i transfer the perl script from windows system to Linux.
And run in Linux system , i get wrong date/time.
Need some help. Thanks.
The source code in Perl
if (($file =~ m/(\d)(\S+)\.csv/) && ($flag == 0))
{
open(para_file,$file);
$datetime_string = ctime( stat($file)->ctime );
while ($line=<para_file>)
{
if ($line =~ /0\,170\,16\,/)
{
$cal = $cal + 1;
}
}
push(#data,"$cal");
push(#data,"$datetime_string");
}
$file will be my file name. The windows date & time on create are correct but don't understand why in LINUX it give me the wrong date & time.
Output of generation , from windows
9023-0 50000 5111 10.22 Mon Jul 21 17:44:38 2014
9023-2 100000 23251 23.25 Fri Apr 11 10:12:19 2014
9024_AHG 5000 0 0.00 Thu Nov 27 15:28:55 2014
Output of generation , from linux
9023-0 50000 5111 10.22 Thu Jul 30 16:45:25 2015
9023-2 100000 23251 23.25 Thu Jul 30 16:45:25 2015
9024_AHG 5000 0 0.00 Thu Jul 30 16:45:25 2015
The problem here isn't what you're doing, it's that you misunderstand what ctime is. Linux filesystems record a change time not a creation time.
mtime denotes modification of file content. ctime denotes modification of attributes. As a result, they may well be the same number.
However what you cannot get is "create time" because the EXT filesystem doesn't record it. (Other filesystem formats may - NTFS for example - but I'm not sure I'd suggest using NTFS on a Linux box!)

cron command runs but does not know the date or time

Perhaps I'm just missing something simple so here goes.
I have a webmin server on Ubuntu and also OpenGTS on a vps, everything works fine and I set it all up from scratch.
I have a cron job like this:
bash /usr/local/OpenGTS_2.5.0/bin/trim.sh
trim.sh is:
#!/bin/sh
MAILTO=me#mymail.net
cd /usr/local/OpenGTS_2.5.0/bin/
./admin.sh Device -account=vehicles -device=laguna -deleteOldEvents=-5d -confirmDelete
This should delete old entries from the database older than 5 days
When run from command line it outputs correctly
Entry Point: org.opengts.db.tables.Device
Deleting events before "Wed Jun 11 23:59:59 BST 2014" ...
Device: laguna - Deleted 0 old events (Saved last event, Nothing to delete)
However when it runs from cron
Entry Point: org.opengts.db.tables.Device
Deleting events before "Mon Jun 09 23:59:59 BST 2014" ...
Device: laguna - Deleted 0 old events (Empty range)
If I set it to 1 day, or 2 days it still insists on Mon Jun 09 23:59:59 BST 2014
I'm totally stumped, any ideas ?
thanks

How to remove terminal control escape sequences in the file?

I got a log from remote linux computer. It looks like:
2013-10-23T08:19:05+0300 Last login: Wed Oct 23 08:17:38 EEST 2013 from 10.9.167.55 on pts/0
2013-10-23T08:19:05+0300 Last login: Wed Oct 23 08:19:05 2013 from 10.9.167.55^M
2013-10-23T08:19:07+0300 ^[[?1034h-bash-4.1$ date
2013-10-23T08:19:07+0300 Wed Oct 23 08:19:07 EEST 2013
2013-10-23T08:19:08+0300 -bash-4.1$ ls
2013-10-23T08:19:08+0300 ^[[0m^[[01;34m99^[[0m #avail.info ^[[01;34mgmoTemp^[[0m raml21.dtd SNMP4JTestAgentBC.cfg
2013-10-23T08:19:08+0300 an_mainHost_localhost_20131023081654000136.xml #avail.info~ gsh.txt ^[[01;34mresults^[[0m
2013-10-23T08:19:09+0300 ^[[m-bash-4.1$ exit
2013-10-23T08:19:09+0300 logout
But it should be:
Last login: Wed Oct 23 08:17:38 EEST 2013 from 10.9.167.55 on pts/0
Last login: Wed Oct 23 08:19:05 2013 from 10.9.167.55
-bash-4.1$ date
Wed Oct 23 08:19:07 EEST 2013
-bash-4.1$ ls
99 #avail.info gmoTemp raml21.dtd SNMP4JTestAgentBC.cfg
an_mainHost_localhost_20131023081654000136.xml #avail.info~ gsh.txt results
-bash-4.1$ exit
logout
The messy codes are terminal control escape sequences, you can use command "infocmp xterm" and "man terminfo" to get more details.
My question is how can I remove these terminal control escape sequences in the file?
Thanks a lot!
Simple way to remove most parts of the control character is using the command below in vim:
:%s/<escape-key>\[[0-9;]*m/ /g
Press Ctrl+V followed by esc-key for the <escape-key> character above. Everything else is the same literal key as in your keyboard.
i use a pipe or direct sed like this
sed 's/[^[:print:]]\[[^a-zA-Z]*[a-zA-Z]//g' YourFile
I solved this issue using lots of regular expressions according to http://invisible-island.net/xterm/ctlseqs/ctlseqs.html

Monitor a process [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
Is there a way I a process can be monitor and if it were to die, can a script be called which in turn will bring the process back up ?
#!/bin/bash
while true
do
if pgrep myprocess >/dev/null ;then
echo "up"
else
echo "down"
/path/to/myprocess &
fi
sleep 60
done
or you could remove the while loop and sleep and put the script in a cron job set to run every minute
monit.
http://mmonit.com/monit/
I wrote one of these a while ago called relight. There also exist more robust solutions, but this one is simple and works for me.
The easiest thing to do is have the initial parent do the monitoring. EG,
#!/bin/sh
while true; do
cmd
# When you get here the process has died. start
# the loop again and restart it
done
This script is liable to be killed so you might want
to trap signals, but the same will be true of any
monitor that you might write. You will probably
also want to insert a delay if cmd is terminating
immediately, or add some logging (call logger
after you call cmd). There's no need to get fancy.
Using a command that you specify in a simple configuration file, Supervisor can start, monitor, and restart a process that unexpectedly dies.
Consider the following Supervisor configuration file fragment in /etc/supervisor/conf.d/forever.conf which displays the date and time every second:
[program:forever]
command=/bin/bash -c 'while true; do echo "Current time is `date`"; sleep 1; done;'
Program forever starts with PID 15474:
derek#derek-lubuntu:~/Projects/fire$ sudo supervisorctl status forever
forever RUNNING pid 15474, uptime 0:00:17
derek#derek-lubuntu:~/Projects/fire$ sudo supervisorctl tail forever
Current time is Fri Jul 7 17:11:10 EDT 2017
Current time is Fri Jul 7 17:11:11 EDT 2017
Current time is Fri Jul 7 17:11:12 EDT 2017
Current time is Fri Jul 7 17:11:13 EDT 2017
Current time is Fri Jul 7 17:11:14 EDT 2017
Current time is Fri Jul 7 17:11:15 EDT 2017
Current time is Fri Jul 7 17:11:16 EDT 2017
Current time is Fri Jul 7 17:11:17 EDT 2017
Current time is Fri Jul 7 17:11:18 EDT 2017
Current time is Fri Jul 7 17:11:19 EDT 2017
Current time is Fri Jul 7 17:11:20 EDT 2017
Current time is Fri Jul 7 17:11:21 EDT 2017
Current time is Fri Jul 7 17:11:22 EDT 2017
Current time is Fri Jul 7 17:11:23 EDT 2017
Current time is Fri Jul 7 17:11:24 EDT 2017
Current time is Fri Jul 7 17:11:25 EDT 2017
Kill the forever process and Supervisor restarts it automatically with new process ID 15760:
derek#derek-lubuntu:~/Projects/fire$ sudo kill 15474
derek#derek-lubuntu:~/Projects/fire$ sudo supervisorctl status forever
forever RUNNING pid 15760, uptime 0:00:02
derek#derek-lubuntu:~/Projects/fire$ sudo supervisorctl tail forever
Current time is Fri Jul 7 17:11:21 EDT 2017
Current time is Fri Jul 7 17:11:22 EDT 2017
Current time is Fri Jul 7 17:11:23 EDT 2017
Current time is Fri Jul 7 17:11:24 EDT 2017
Current time is Fri Jul 7 17:11:25 EDT 2017
Current time is Fri Jul 7 17:11:26 EDT 2017
Current time is Fri Jul 7 17:11:27 EDT 2017
Current time is Fri Jul 7 17:11:28 EDT 2017
Current time is Fri Jul 7 17:11:29 EDT 2017
Current time is Fri Jul 7 17:11:30 EDT 2017
Current time is Fri Jul 7 17:11:31 EDT 2017
Current time is Fri Jul 7 17:11:32 EDT 2017
Current time is Fri Jul 7 17:11:33 EDT 2017
Current time is Fri Jul 7 17:11:34 EDT 2017
Current time is Fri Jul 7 17:11:35 EDT 2017
Current time is Fri Jul 7 17:11:36 EDT 2017
If you are using SysV system (not Upstart), you can put the process do respawn at inittab.
Just edit your /etc/inittab file and add a line like this:
proc:12345:respawn:/path/to/process
There are number of ways of getting the task done:
As suggested by others - Run a script to check if process is running, restart the process if not running. To check you if process is running or not you can use pgrep <process name> | wc -l
Use watch command to run a script after some interval to check if process is running, if not then restart the process
Create a parent process, that will always look for the child process, if child process crashes or stops, parent will be notified, then restarts new process.
systemd is a sophisticated process manager available on most major Linux distributions.

Resources