Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7063363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:42:17+00:00 2026-05-28T04:42:17+00:00

How can I get tar/cp to copy only files that dont end in .jar

  • 0

How can I get tar/cp to copy only files that dont end in .jar and only in root and /plugins directories?

So, I’m making a Minecraft server backup script. One of the options I wish to have is a backup of configuration files only. Here’s the scenario:

  1. There are many folders with massive amounts of data in.
  2. Configuration files mainly use the following extensions, but some may use a different one:
    • .yml
    • .json
    • .properties
    • .loc
    • .dat
    • .ini
    • .txt
  3. Configuration files mainly appear in the /plugins folder
  4. There are a few configuration files in the root directory, but none in any others except /plugins
  5. The only other files in these two directories are .jar files – to an extent. These do not need to be backed up. That’s the job of the currently-working plugins flag.

The code uses a mix of tar and cp depending on which flags the user started the process with.
The process is started with a command, then paths are added via a concatenated variable, such as $paths = plugins world_nether mysql/hawk where arguments can be added one at a time.

How can I selectively backup these configuration files with tar and cp? Due to the nature of the configuration process, we needn’t have the same flags to add into both commands – it can be seperate arguments for either command.

Here are the two snippets of code in concern:
Configure paths:

# My first, unsuccessful attempt.
if $BKP_CFG; then
    # Tell user they are backing up config
    echo " +CONFIG $confType - NOT CURRENTLY WORKING"
    # Main directory, and everything in plugin directory only
    # Jars are not allowed to be backed up
    #paths="$paths --no-recursion * --recursion plugins$suffix --exclude *.jar"
fi

—More Pro Stuff—-

# Set commands
if $ARCHIVE; then
    command="tar -cpv"
    if $COMPRESSION; then
        command=$command"z"
    fi
    # Paths starts with a space </protip>
    command=$command"C $SERVER_PATH -f $BACKUP_PATH/$bkpName$paths"
    prep=""
else
    prep="mkdir $BACKUP_PATH/$bkpName"
    # Make each path an absolute path. Currently, they are all relative
    for path in $paths; do
        path=$SERVER_PATH/$path
    done
    command="cp -av$paths $BACKUP_PATH/$bkpName"
fi

I can provide more code/explaination where neccessary.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:42:18+00:00Added an answer on May 28, 2026 at 4:42 am
    find /actual/path ! -iname '*jar' -maxdepth 1 -exec cp \{\} /where/to/copy/ \;
    find /actual/path/plugins ! -iname '*jar' -maxdepth 1 -exec cp \{\} /where/to/copy/ \;
    

    Might help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get files like this below: GT-I5500-CSC-SERJK1.tar.md5 This is what I want: GT-I5500-CSC-SERJK1.tar How
How do I get ruby-debug to run under XP so that I can step
Where can I get a vanilla tar.gz binary build download of openjdk7 for linux,
Can get all triples with value null in specific field? All people with date_of_birth
We can get class Class object by 3 methods: MyClass.class obj.getClass Class.forName(className) I don't
I can get the file path with: (message (file-name-directory (or buffer-file-name load-file-name))) But if
I can get this to work: [<DllImport(user32.dll)>] extern bool GetClientRect(nativeint, RECT*) let getClientRect hwnd
You can get the nodes of the document object of an <iframe> with the
You can get underground processes by ps ux I am searching a way to
You can get a list of databases using PRAGMA database_list or a list of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.