LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-03-2021, 12:58 AM   #1
harun2k
LQ Newbie
 
Registered: Nov 2021
Posts: 3

Rep: Reputation: Disabled
Write a script that automates tar so the person executing the script always uses the desired options (cvp) and backup destination


Can someone please provide me a script for this question.
Write a script that automates tar so the person executing the script
always uses the desired options (cvp) and backup destination
 
Old 11-03-2021, 01:04 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 5,971
Blog Entries: 3

Rep: Reputation: 3102Reputation: 3102Reputation: 3102Reputation: 3102Reputation: 3102Reputation: 3102Reputation: 3102Reputation: 3102Reputation: 3102Reputation: 3102Reputation: 3102
Welcome. That sounds very much like a homework question. We don't do your homework for you but we can help you over the hard parts when you show what you've done so far and explain where you are stuck. So please show what you've done so far and explain where you are stuck.

If you are looking for introductions to shell scripting, there are lots of guides out there but I would recommend ordering a copy of The Linux Command Line by William Shotts and working through to part 4 of the book. Your local technical college might also have it or else be able to get it via Inter-Library Loan if budgeting is a barrier.
 
Old 11-03-2021, 01:07 AM   #3
GentleThotSeaMonkey
Member
 
Registered: Dec 2016
Posts: 236
Blog Entries: 3

Rep: Reputation: 76
Exercise #3 in tldp.org/LDP/Bash-Beginners-Guide/html/sect_08_04.html

forums.overclockers.co.uk/threads/bash-script-full-incremental-backups-help.18760663 appears to have one student's answer.

Last edited by GentleThotSeaMonkey; 11-03-2021 at 01:11 AM.
 
1 members found this post helpful.
Old 11-03-2021, 01:32 AM   #4
harun2k
LQ Newbie
 
Registered: Nov 2021
Posts: 3

Original Poster
Rep: Reputation: Disabled
Is this correct?

# What to backup.
datapath='/home'#
Where to backup to.
backuppath="/var/backup"
# Backup the files using tar.
filename=$(date +%u-%a-%Y%m%d)
tar -zcf $backuppath/$filename $fullbackup.tar.gz -g
# Print end status message.
echo
echo "Backup finished"
 
Old 11-03-2021, 07:05 AM   #5
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,037

Rep: Reputation: Disabled
Cross-post @linux.org. Answered there.

Last edited by shruggy; 11-03-2021 at 07:07 AM.
 
Old 11-03-2021, 08:28 AM   #6
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,224
Blog Entries: 1

Rep: Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585
But at least the OP is consequent: doesn't use the [code] and [/code] tags neither here or there.
 
Old 11-03-2021, 09:14 AM   #7
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 24,296

Rep: Reputation: 7140Reputation: 7140Reputation: 7140Reputation: 7140Reputation: 7140Reputation: 7140Reputation: 7140Reputation: 7140Reputation: 7140Reputation: 7140Reputation: 7140
Quote:
Originally Posted by harun2k View Post
Code:
# What to backup.
datapath='/home'# 
Where to backup to.
backuppath="/var/backup"
# Backup the files using tar.
filename=$(date +%u-%a-%Y%m%d)
tar -zcf $backuppath/$filename $fullbackup.tar.gz -g
# Print end status message.
echo
echo "Backup finished"
You asked if it was correct; so why don't you RUN the script and see if it works?? There are also shell script checking sites that can tell you if there are errors in your scripts, which can be handy too. But asking people to write your scripts for you is plain rude and lazy....read the "Question Guidelines".
 
Old 11-03-2021, 10:02 AM   #8
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_12{.0|.1}
Posts: 5,777
Blog Entries: 23

Rep: Reputation: 3785Reputation: 3785Reputation: 3785Reputation: 3785Reputation: 3785Reputation: 3785Reputation: 3785Reputation: 3785Reputation: 3785Reputation: 3785Reputation: 3785
Please review the Site FAQ for guidance in asking well formed questions. Especially visit the link from that page, How to Ask Questions the Smart Way for discussion of things to consider when asking others for help.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] find uid of a person and how many times that person is logged on. gursewaks056 Ubuntu 2 10-28-2017 06:34 AM
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 03:48 AM
BackUp & Restore with TAR (.tar / .tar.gz / .tar.bz2 / tar.Z) asgarcymed Linux - General 5 12-31-2006 03:53 AM
How do I un tar a .tar, .tar.z, .tar.gz file vofkid Linux - Newbie 4 03-15-2002 03:54 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration