Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Simple backup for gentoo?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
avgen2
n00b
n00b


Joined: 27 Jun 2022
Posts: 37

PostPosted: Thu Aug 04, 2022 12:24 pm    Post subject: Simple backup for gentoo? Reply with quote

I learned the hard way that backing up is important but manual backup is really started to get frustrating. I even have a hard time figuring out what I'm backing up to where and which one is up to date.

Anyway, I found rsnapshot to be good for backup but crontab is really confusing. I want to use crontab but as far as I see on the internet I do not understand how to set it as time because my computer is not a server. I turn off my computer in the morning, but sometimes I turn it off in the evening. I just want to work with the script ones if the files change. If this is difficult to do, it can also be as follows:

hourly - > works from 8 am / 11 pm, but 4 times or 5 times.
daily, weekly, monthly -> just 1 time or 2 times.

The home folder is not separeted, but I plan to separate it when the system breaks down.

I just want to backup this folder:
/home/
xinitrc, bashrc, zshrc, .mozilla, .config, makeconf etc.(i try to make my linux settings completely permanent)
Update: I want to add / (for make.conf, etc and important config files)file too but exclude unnecacery (mnt, media, dev,run etc.) things because ı just want to backup .config files. How to do it easy way?
_________________
English is not my native language; please excuse typing errors. You are free to correct me if you want.


Last edited by avgen2 on Fri Aug 05, 2022 11:13 am; edited 1 time in total
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3129

PostPosted: Fri Aug 05, 2022 12:36 am    Post subject: Reply with quote

Quote:
I do not understand how to set it as time because my computer is not a server
Use @frequency tags or put your script (or link to a script) inside /etc/cron.<frequency>, e.g. /etc/cron.daily for daily backup.
This is a non-standard feature, you will need a cron daemon which understands @-syntax or anacron for this to work.

They will run your tasks whenever possible but no more frequently than your defined frequency.
In your case this means that a backup missed to your PC being shut down will be triggered within a few minutes after booting up.
Back to top
View user's profile Send private message
avgen2
n00b
n00b


Joined: 27 Jun 2022
Posts: 37

PostPosted: Fri Aug 05, 2022 9:27 am    Post subject: Reply with quote

szatox wrote:
Use @frequency tags or put your script (or link to a script) inside /etc/cron.<frequency>, e.g. /etc/cron.daily for daily backup.
This is a non-standard feature, you will need a cron daemon which understands @-syntax or anacron for this to work.


I am newbie with cronie. I just understand this: I need to create rsnapshot script to cron.daily and use anacron for start this script.
I already create rsnapshot script on cron.daily/rsnapshot.daily:
Code:
#!/bin/sh
echo "### RSNAPSHOT DAILY ###"
mount /mnt/backup && rsnapshot daily || echo "Backup failure"
umount /mnt/backup
echo ""


but this last rsnapshot didn't worked for me. I am using cronie. anacron:
Code:
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=""
START_HOURS_RANGE=7-24
# format: period delay job-identifier command
##
## If you turn any of the following on, make sure that the
## regular cron daemon does not run them also. This could
## lead to double execution of the jobs.
#period in days   delay in minutes   job-identifier   command
1       5       cron.daily      run-parts /etc/cron.daily
7       10      cron.weekly     run-parts /etc/cron.weekly
30      15      cron.monthly    run-parts /etc/cron.monthly

#1   10   daily-snapshot   /usr/bin/rsnapshot daily
#7   20   weekly-snapshot   /usr/bin/rsnapshot weekly

I think my permissions did this issue. What need to do with rsnapshot, cron permissions?
Code:
-rwxr-xr-x 1 root root 130 Aug  1 20:55 rsnapshot.daily
-rw-r--r-- 1 root root 655 Aug  5 12:01 /etc/anacrontab

szatox wrote:

They will run your tasks whenever possible but no more frequently than your defined frequency.
In your case this means that a backup missed to your PC being shut down will be triggered within a few minutes after booting up.


Am I need to write script for frequency or anacron handle that?
_________________
English is not my native language; please excuse typing errors. You are free to correct me if you want.
Back to top
View user's profile Send private message
xineg
Tux's lil' helper
Tux's lil' helper


Joined: 14 Mar 2006
Posts: 115
Location: Australia.

PostPosted: Sat Aug 06, 2022 2:35 am    Post subject: Reply with quote

I have cronie also but not anacron. The easiest way to start is using the program crontab. crontab will allow you to do things like (say) list cronjobs for specific users, edit your jobs, delete your jobs, and so on. It does this in the easiest way possible really. As an example, lets say you want root to run the backup script/program backup.sh once a day, i.e daily but at no specific time, just like szatox was saying to you. To do this run crontab with the -e option (for edit):
Code:
~# crontab -e

it will then open up in your editor where you would put the @daily and what you wish to run:
Code:
@daily /path/to/program/backup.sh

save that and all should be good. crontab will tell you if it's syntactically correct or there is a problem.
Initially this will get you started. To list your cronjobs use the -l option, or if you want to see all the other
ways to setup jobs in your crontab do
Code:
man 5 crontab

Of course make sure you have started the cronie daemon otherwise nothing will happen at all.
Back to top
View user's profile Send private message
wjb
l33t
l33t


Joined: 10 Jul 2005
Posts: 605
Location: Fife, Scotland

PostPosted: Sat Aug 06, 2022 11:12 am    Post subject: Reply with quote

I prefer to run backups in a specific time bracket, to avoid accidentally shutting down during a backup and to avoid busy times. So times when I'm cooking/eating work for me. This is probably overkill since I use borg and it usually takes less than 5min for a daily backup.

fcron
Code:

%hours * 19-20 * * *  /usr/sbin/my-borg-backup
Back to top
View user's profile Send private message
cboldt
Veteran
Veteran


Joined: 24 Aug 2005
Posts: 1046

PostPosted: Sat Aug 06, 2022 11:59 pm    Post subject: Reply with quote

cron frequency can be variable with a simple trick. Entries here are for a USER, not as appear in /etc/crontab, but the method to get a frequency other than hourly, by the minute, daily, etc. works from either a personal crontab or the system crontab. First example runs each ten minutes ...

Code:
*/10 *  * * *           online rsync --inplace domainname.org:.procmail/log ~/.procmail/log > /dev/null 2>&1


Being repetitive, that line will execute each 10 minutes, any minutes value that is divisible by 10. Same thing can be done in the hours field. Say you want to run something at 13 minutes after each 3 hours ...

Code:
13 */3  * * *           online rsync --inplace domainname.org:.procmail/log ~/.procmail/log > /dev/null 2>&1


I use rsync filter method to exclude and include files in slightly more complex backup routines.

Code:
# /etc/rsync.filter
#
# This file aims to be common between hypoid, hypoid-2, and involute
# It is intended to save the system and /home, as well as limited parts
# of /backup and /public, if those exist
#
# This include/exclude filter is used in `backup-usb` and `toinvolute`
#
# rsync -a --inplace --delete --delete-excluded \
#    --filter='merge /etc/rsync.filter' \
#    --stats
#
# `toinvolute` is not used FROM involute, and is common between hypoid laptop machines
# `backup-usb` can be used from any machine.  Two versions of that script exist:
# involute: `backup-usb` backs up to two separate drives, multiple redundancy
# others:   `backup-usb` backs up to one external drive mounted either locally or at involute
#
# A separate set of rsync commands is in involute's `/usr/local/sbin/backup mirror`

+ /lost+found/
- lost+found
+ /dev/console
+ /dev/null
- /dev/**
- /media/**
- /misc/**

# One asterisk, copies names of mount points (recurse =1), but no contents
# a '*' matches any path component, but it stops at first slash.
# /mnt/sysrescue is at hypoid-t450 and contains grub configuration and support
+ /mnt/*
+ /mnt/sysrescue/**
- /mnt/**

- /proc/**
- /sys/**
- /run/**
- /tmp/**
- /var/tmp/**

# MTA spool contents
# Save /var/spool/mail - users mail

+ /var/spool/exim/*
- /var/spool/exim/**
+ /var/spool/postfix/*
- /var/spool/postfix/**
+ /var/spool/mail/*

- /var/spool/cups/**

# Save locations for Gentoo binary packages
# hypoid:       /public/packages
# hypoid-2:     /public/packages/
# hypoid-t450:  /var/cache/binpkgs
# involute:     /var/cache/binpkgs
+ /public/packages/**
+ /var/cache/binpkgs/**
# Don't save portage tree.  It can be rebuilt or copied.
- /var/db/repos/gentoo/**

# Don't save copies of distfiles
# hypoid:       /public/distfiles/
# hypoid-2:     /public/distfiles
# hypoid-t450:  /var/cache/distfiles
# involute:     /public/distfiles
- /public/distfiles/**
- /var/cache/distfiles/**

# Don't save working files that have only transient purpose
- FVWM-reports
- Lynx.trace
- [Cc]ache
- .adobe/**
- .cache/**
- mbackup/**
- .mozilla/firefox/*/storage/**
- *.o
- .pine-debug*
- /home/tmp/**
Back to top
View user's profile Send private message
figueroa
Advocate
Advocate


Joined: 14 Aug 2005
Posts: 2956
Location: Edge of marsh USA

PostPosted: Sun Aug 07, 2022 4:34 am    Post subject: Reply with quote

Search the forums for backups and system backup for past discussions. I think borgbackup is used by a fair number of users and I like what I read about it, but I'm not a user. I roll my own scripts. For a system not running 24/7, learn how to use anacron, especially if you want to use your own scripts. If you have cronie installed, /usr/sbin/anacron comes from cronie.

Anything you fail to backup, you are certain to need. There are good reasons to backup everything. My system backup is a zstd compressed tar archive (also called a stage4 archive) of everything except personal files run about 4 GB, and can be easily restored to another partition to create a duplicate Gentoo installation, or restored to a new disk in the event of disk failure.

Here is a good, recent thread about system backups that includes my posting about my stage4 script(s). https://forums.gentoo.org/viewtopic-t-1132899-start-0-postdays-0-postorder-asc-highlight-stage4%2Bbackup.html
_________________
Andy Figueroa
hp pavilion hpe h8-1260t/2AB5; spinning rust x3
i7-2600 @ 3.40GHz; 16 gb; Radeon HD 7570
amd64/23.0/split-usr/desktop (stable), OpenRC, -systemd -pulseaudio -uefi
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum