Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I would like to start making a .tar of the /home/ directory and moving that file to my NAS nightly. Can this be done? I would assume it would need to be able to run as the superuser regardless if someone is logged on or not. I am running Ubuntu Mate 17.10.
1. Yes, your backup process will need superuser (root) authority to back up files and folders that belong to different users.
2. Why tar? Just curious, I have used tar for backups at times myself. Have you considered using a real backup application?
I set up a different server and ran burp for backups. It gave me generational restores to specific dates without wsted space. (burp does deduplication at the block level, and uses the rsync libraries so that a backup for a specific date does not waste space or bandwidth.)
I'd also use rsync. It would save a lot of time and wear and tear on the discs, relative to tar. You can also use it for incremental backups. There are a lot of tutorials about using the --link-dest option for that.
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
tar is from the tape backup era and AFAIK it does not serve any purposes for backup anymore. (This is not to say tar isn't useful. In all other cases it is). If you backup to NAS it is way better to backup your individual files so you have instant access.
rsync is good, but not perfect regarding keeping multiple backups for different points in time.
rsnapshot, built around rsync plus --link-dest does provide this option. It keeps multiple backups and only storing the differences between subsequent backups.
I would like to start making a .tar of the /home/ directory and moving that file to my NAS nightly. Can this be done? I would assume it would need to be able to run as the superuser regardless if someone is logged on or not. I am running Ubuntu Mate 17.10.
Thanks!!
yes, it is possible, and just a single command (as root). But actually I don't know what is your real problem.
+1 for rsnapshot
We use it to backup a production server remotly daily. Been awhile since the first run, but I think that took about three hours. Now it backs up changes daily in about 11 minutes.
Thanks for all your replies! Going with the RSYNC command, how do I go about writing a script to run daily, as root, regardless if someone is logged in. (I normally keep myself logged in).
Sorry for the newbie question, but that is what I am.
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
The simple rsync command works if you want to backup below the root directory (such as /home in this example). And it fails surprisingly when the backup drive is not mounted. That is, disk space on the mount point partition will be filled up completely and services start to fail.
My preference is a short bash script which is called from cron.
Code:
#!/bin/bash
mount_point='/mnt/ext_daily'
# Find if the device is mounted
df -h | grep $mount_point > /dev/null
if [ $? -eq 0 ]
then
rsync -uav --exclude='/mnt' --exclude='/proc' --exclude='/sys' --delete / /mnt/ext_daily > /var/log/rsync_daily
echo "mount point $mount_point exists, rsync started"
else
echo "Error: mount point $mount_point does not exist, rsync operation skipped"
fi
Echo statements go into /var/log/syslog if executed from cron. Double check the source and destination dir in the rsync command if you use --delete. Better run the first time without --delete until you are sure source and destination are correct.
The command in /etc/crontab:
Code:
59 4 * * * root /bin/sh /root/rsync_daily.sh
Note that you use either root's crontab with crontab -e as in the example above. Or you edit /etc/crontab directly. The syntax is slightly different as the 6th column specifies the user which executes the command.
Take a look at http://dirvish.org/ it uses rsync but also allows you to create differential/versional backups, so you can go back to files at different points in time easily and without backup up everything every single time.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.